필터 지우기
필터 지우기

creating vector in matlab fcn bock

조회 수: 2 (최근 30일)
sia
sia 2013년 9월 13일
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
Simon
Simon 2013년 9월 13일
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 2013년 9월 13일
Hi, thank for the answer. But what do u mean with "Pasting your code in a function file and executing" ???

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

답변 (3개)

Simon
Simon 2013년 9월 13일
Hi!
If you have trouble defining functions in Matlab, start here: http://www.mathworks.com/help/matlab/matlab_prog/create-functions-in-files.html

Kaustubha Govind
Kaustubha Govind 2013년 9월 13일
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 2013년 9월 23일
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

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by