How do u pass the data calculated from the previous function to another function

How do u pass the data calculated from the previous function to another function

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2011 年 11 月 11 日
abs() is a function, so is sin().
a=-3;
b=abs(a);
c=sin(b);
or
sin(abs(-3))
Does this answer your question?

5 件のコメント

Walter Roberson
Walter Roberson 2011 年 11 月 11 日
Notes:
- This only works for values returned by a function. Values that are calculated by a function but not returned are discarded unless special precautions are taken to preserve them.
- Combining the two calls in to one expression only works for the first output returned by a function. If a function returns multiple arguments and you need the additional outputs, then you must assign the result to variables (which you can then pass in to the next call.)
komal Bhandari
komal Bhandari 2011 年 11 月 11 日
I mean to say it is a user defined function not a matlab funvtion.
Fangjun Jiang
Fangjun Jiang 2011 年 11 月 11 日
It's the same!
Fangjun Jiang
Fangjun Jiang 2011 年 11 月 11 日
Maybe you should note that you need to make your function have an output argument.
function out=plus_one(in)
out=in+1;
function out=time_two(in)
out=2*in;
time_two(plus_one(1)) would yield 4.
Jan
Jan 2011 年 11 月 11 日
@komal: You can read the code of e.g. MEAN: "edit mean.m". This is a function of a Matlab toolbox, but it is exactly the same mechanism as for user-defined functions. There are a lot of further good examples in the documentation and in the toolboxes.

この質問は閉じられています。

タグ

質問済み:

2011 年 11 月 11 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by