function

조회 수: 1 (최근 30일)
God'sSon
God'sSon 2011년 5월 18일
I am trying to call another function(add) from within my code but i get the following error. Can any one please help.
a=[1 2 3 4 5 6]
[b]=add(a)% the commands of add actually produces d
c=a+d
??? Undefined function or variable "d".
  댓글 수: 1
Jan
Jan 2011년 5월 18일
You could show us the code of "add" to clarify what "actually produces d" means.

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

채택된 답변

Sean de Wolski
Sean de Wolski 2011년 5월 18일
No. The command add may produce 'd' in its own function workspace, but when it is retrieved it is called 'b' because that's the variable name you're assigning it to.
Did you want:
d = add(a); ?
Or did you want add to put a d in your workspace?
doc assignin
  댓글 수: 3
Sean de Wolski
Sean de Wolski 2011년 5월 18일
function [f d] = add(x)
%do stuff with x to create f and d; e.g.
f = x*pi
d = 11./x
call add with
[f d] = add(a)
or whatever.
doc function for a good description of how they work
God'sSon
God'sSon 2011년 5월 19일
This works fine. Thank you.

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by