simulink error related to diff of a vector

I am using a function block in simulink. suppose "score" is a vector of size [1000 1]. i store the index of the maximum value in score in ind3 : [~, ind3] = max(score); I know that the initial value of ind3 = 1. Then i want to store something like: storing = sum(diff(score(1,1:ind3)).^2), which will be the output of the function block. But, i keep getting error message related to variable matrix sizes such as
SUM with one variable-size matrix input of [] is not supported. Block MATLAB Function2 (#100) While executing: none
I have noticed that i do not get any error if i use something like storing = sum(diff(score(1,1:100)).^2) but as soon as i put ind3, i get the errors.
Thank you

댓글 수: 6

Ryan G
Ryan G 2013년 5월 15일
Is the result of storing variable size? What is the output if you run this in MATLAB? Will storing every be an empty matrix? These things are much less flexible in Simulink as you are required to define a fixed size.
pemfir
pemfir 2013년 5월 15일
i actually ran this before posting this on matlab, it works fine without any problem. The problem is related to variable size, but the thing is that storing is a scalar .... i am confused ..
Are you using a MATLAB Function Block or a Fcn Block? Try predefining the output of your function, for example:
storing = double(0);
If it's a scalar. Is it running at all or just failing to initialize?
pemfir
pemfir 2013년 5월 15일
It is a matlab function block, i added strong = souble(0) , i still get the same problem. it fails at initialization. Also tried to go to Edit data and define storing as data store memory with variable size checked and unchecked. storing is not the output, it is just a variable inside the function.
pemfir
pemfir 2013년 5월 15일
Another error i get : The working dimension was selected automatically, is variable-length, and has length 1 at run-time. This is not supported. Manually select the working dimension by supplying the DIM argument.
pemfir
pemfir 2013년 5월 16일
any help will be appreciated

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Event Functions에 대해 자세히 알아보기

질문:

2013년 5월 15일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by