assigning a vector to a function

조회 수: 11 (최근 30일)
cgo
cgo 2015년 10월 29일
편집: Thorsten 2015년 10월 29일
I made a function that returns a vector as a response. I noticed that this vector is not 'stored' as I check the workspace. So I attempted to say A = FUNCTION(X,Y). But it returned 'ERROR USING FUNCTION. TOO MANY OUTPUT ARGUMENTS'.
I want to store the response given by the function in a vector so I can use it in the future. How do i do this?
Thanks

채택된 답변

Thorsten
Thorsten 2015년 10월 29일
편집: Thorsten 2015년 10월 29일
It seems that you have not defined your function properly.
In an m-file called myfun.m you write
function A = myfun(X,Y)
A = X + Y; % or whatever the function should compute
Then you call it using, e.g.,
a = myfun(x,y);
See also
help function

추가 답변 (1개)

Ingrid
Ingrid 2015년 10월 29일
you do not have enough information in your question, why do you not add the relevant code?
if in your function file you have started it with
function A = FUNCTION(X,Y)
...
you should be able to use it as such. Your error message seems to indicate that your function is not returning a vector as a response although you have indicated this is the case

카테고리

Help CenterFile Exchange에서 Phased Array Design and Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by