Function does not calculate desired variable.
1 vue (au cours des 30 derniers jours)
Hi I have the following function;
function [EV,N,t,S] = EVjc300293(EV,N,t,S)
% If a variable is set to zero calculate its value.
% 1. Choose which variable to process.
EV = log2((N^2)/t)-log2(S/100);
N = sqrt((2^(EV+log2(S/100)))*t);
t = (N^2)/(2^(EV+log2(S/100)));
S = 100/(2^(EV-log2((N^2)/t)));
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?
Plus de réponses (1)
Chandrasekhar le 20 Mai 2014
In the function that you have written EV, N ,t,s are in separate if -else if conditions and only on of them executes at a time.
in you case if EV==0 is getting satisfied and hence only EV is being calculated and the else if and else conditions are not getting executed.
one solution is to assign a default value for all the value at the beginning of the function.