Hi I have the following function;
function [EV,N,t,S] = EVjc300293(EV,N,t,S)
if EV==0
EV = log2((N^2)/t)-log2(S/100);
elseif N==0
N = sqrt((2^(EV+log2(S/100)))*t);
elseif t==0
t = (N^2)/(2^(EV+log2(S/100)));
elseif S==0
S = 100/(2^(EV-log2((N^2)/t)));
end
end
I want to make it so that if a variable is set to zero in the function its value is calculated. I wish to do this using the if elseif statements listed. However when I run it it always calculates EV and not any other variable?
Thanks.
2 Comments
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/130326-function-does-not-calculate-desired-variable#comment_214794
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/130326-function-does-not-calculate-desired-variable#comment_214794
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/130326-function-does-not-calculate-desired-variable#comment_214796
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/130326-function-does-not-calculate-desired-variable#comment_214796
Sign in to comment.