In an assignment A(I) = B, the number of elements in B and I must be the same.
1 view (last 30 days)
Show older comments
Hi, I'm getting following error:
In an assignment A(I) = B, the number of elements in B and I must be the same.
... even though the number of elements are the same. I displayed their values and their number of elements to check this.
This is my code:
CS = 1;
STROOM = zeros(1,10);
STROOMB = zeros(1,10);
Counter = 0;
switch state
case STATE.READ % present state is READ
CS=0;
if (Counter ~= 10);
STROOMB(Counter+1) = Data_Out;
Counter = Counter+1;
next_state = STATE.READ;
This is the output:
(3) RUNNING TEST test
1
1
??? Error using ==> Model_run at 71
Error in 'Model_ADConverter/FSM_template/S-Function' while executing MATLAB S-function 'FSM_ADConverter', flag = 3 (output), at
time 0.0.
Caused by:
Error using ==> Model_run at 71
In an assignment A(I) = B, the number of elements in B and
I must be the same.
I've been looking hours for a solution (I'm pretty new to Matlab) but can't find it... Does anyone know the answer?
Thanks in advance!
0 Comments
Accepted Answer
Walter Roberson
on 30 Nov 2011
(To exhume the key point towards solving this:)
If you have "clear all" in one of your functions or scripts, comment that out or remove it, as one of the effects of it is to remove all breakpoints and "dbstop" commands.
Once those "clear all" commands are disabled, you can use
dbstop if error
at the MATLAB command line and then run, in order to determine which line is causing the problem.
0 Comments
More Answers (4)
the cyclist
on 29 Nov 2011
Although you have shown us some code, it is too incomplete for us to run and try to reproduce the error. Can you post the smallest possible chunk of code that we would actually be able to run, to reproduce your error?
Are you familiar with breakpoints? You could try adding a breakpoint at the line that errors out, and look at the sizes.
Also, you could use a "try ... catch" structure around the line that gives the error, stopping the code in that way.
Robbe
on 29 Nov 2011
10 Comments
Walter Roberson
on 30 Nov 2011
Sounds like you have a "clear all" in one of your scripts. "clear all" includes removing breakpoints.
Robbe
on 30 Nov 2011
2 Comments
the cyclist
on 30 Nov 2011
I suggest that you start a new thread with this question, rather than burying it here. Also, consider "accepting" the answer here that you received that, if you found one critically helpful.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!