Calling max value of variable from another function
6 views (last 30 days)
I have made a function named "example.m" in which I have created two variables "x" and "y" both have certain range.
function [x,y,T] = example(v,sigma,G,N,K)
Now in another function, named "loadvalues.m" I need to call the maximum value of "y" along with the corresponding value of "x" both of them are loaded in another variable named "loady" and "loadx" respectively. Can someone please tell me how to do this?
dpb on 13 Aug 2017
The y in the function example has nothing to do with the y from the load y command so the question is unclear as to why you're referring to the latter...unless there's code not shown which SAVE d the x and y after you ran the function and you used the intermediary from the disk to get the output of the function later on instead of just saving the results of running the function itself???
If that's the case, IA's Answer is spot, but why not save the intermediary step and write
[x,y,T] = example(v,sigma,G,N,K);
As to the second question, there is only one value of T returned and it will correspond to whichever condition is T in the IF block; the other branch will never be evaluated. If it's important as to which condition is so, you could add another output which is a flag variable that has the value of true/false or 0/1 or -1/+1, whatever set of values you wish to indicate that condition.