简体   繁体   中英

How to use the output of matlab function in another function ?

I'm working on Iris recognition system for my degree project (put in mind i have no background in Matlab and i had no courses or anything in it , but i had to use it to implement my project ><) .

I'd like to ask , how can i use the output of a Matlab function in another function ? Like how to take the output of a function , let's say "Segmentation" function , and pass it or use it in another function , like "Normalization" for example .

Is there any way to store it in a variable or something like that like in other programming languages ? I hope you guys got what i mean & I hope i'll get an answer :)

Thank you :)

Just add an output argument to your first function, and an input argument to your second function, like so:

function theOutput = doSomething()
    theOutput = someValue;

Then, the second function:

function doSomethingElse(theInput)
    disp(theInput); % Will print value of someValue returned from first function, assuming you call doSomethingElse passing this value

If you are unfamiliar with these basic concepts, however, I would recommend reading up on the MATLAB language in general. Remember that the documentation contains a wealth of information on most topics. For this specific problem, see the function keyword documentation.

take 3 minutes to read any matlab getting started guide,

this one for example

http://alice.nc.huji.ac.il/~hvuag/neuromath/math/Matlab_Tutorial.pdf

Matlab is HUGE, and it can take you years to explore every corner, the upside is , that you can be productive from minute 2. the easy things are very much straight forward.

to answer your question, variable assginment is trivial

a=max(1,2)
b=max(a,3)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM