creating vector in matlab fcn bock

hi, i wanna to create a vector in matlab fcn block, that s my Code:
function y = fcn
e = 160;
s = 45;
vector = (s:e);
y = vector
but i get this error: Output 'y' (#4Cool has variable size but the upper bound is not specified; explicit upper bound must be provided.
can u guys help me to solve that?
THX

2 Kommentare

Hi!
I see no problem. Pasting your code in a function file and executing
result = fcn;
gives a resulting vector ranging from 45 to 160.
sia
sia am 13 Sep. 2013
Hi, thank for the answer. But what do u mean with "Pasting your code in a function file and executing" ???

Melden Sie sich an, um zu kommentieren.

Antworten (3)

Kaustubha Govind
Kaustubha Govind am 13 Sep. 2013

0 Stimmen

Please use coder.varsize to define an upper-bound for the output variable as I have previously explained here. You also need to configure the MATLAB Function block for a variable-size output.
Fred Smith
Fred Smith am 23 Sep. 2013

0 Stimmen

For this particular piece of code, variable-sizing should not be needed as the end points are constants. This example works fine for me in a recent version. What version of MATLAB and Simulink are you using?
You can find this out using the ver command: >> ver

Gefragt:

sia
am 13 Sep. 2013

Community Treasure Hunt

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

Start Hunting!

Translated by