How to input data from one function to another one?

조회 수: 1 (최근 30일)
zhe li
zhe li 2011년 11월 9일
Could anybody help me with this please? I have written a function in a m file. I'd like to write another function containing only data required for calculations. I am hoping the first function can take in the data written in the second function, and calculate automatically. Rather than I have to copy and paste the data to the command panel and run the function. If i want to make any change, I can simply change the data in the second function. and run it again. Thank you very much.

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2011년 11월 9일
Write two functions:
function data=Fcn1
data=[1 3 2];
function result=ProcessData(MyData)
result=MyData+1;
In Command Window, you can do:
out=ProcessData(Fcn1)
  댓글 수: 1
zhe li
zhe li 2011년 11월 9일
I see what you mean,however, I have tried similar methods, it is apparently not working. I have always got error as ??? Input argument "S1" is undefined. as I have a list of data in the function,e.g. s1=2,ss1=[2 3 4 5],s2=3,ss2=[4 2 6 8] and so on.

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by