In an assignment A(I) = B, the number of elements in B and I must be the same.
显示 更早的评论
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!
采纳的回答
更多回答(4 个)
Walter Roberson
2011-11-29
0 个投票
What exactly is the size of Data_Out ?
the cyclist
2011-11-29
0 个投票
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
2011-11-29
10 个评论
Walter Roberson
2011-11-29
You appear to have a try / catch / else / end structure, but "else" is not a defined control keyword for try / catch / end blocks.
Robbe
2011-11-29
Walter Roberson
2011-11-29
I think it was the cyclist that suggested adding try/catch .
Walter Roberson
2011-11-29
At the MATLAB prompt, give the command
dbstop in updateFSM
and then run again. It should stop in the debugger at the beginning of the routine.
Robbe
2011-11-29
Walter Roberson
2011-11-29
Must be a subfunction then. In that case, try clicking a breakpoint in to existence in updateFSM. Breakpoints do work when a script is called from another script.
Robbe
2011-11-30
Robbe
2011-11-30
Walter Roberson
2011-11-30
Sounds like you have a "clear all" in one of your scripts. "clear all" includes removing breakpoints.
Robbe
2011-11-30
Robbe
2011-11-30
0 个投票
2 个评论
the cyclist
2011-11-30
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.
Robbe
2011-11-30
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!