how to display/table numbers and letters

4 Ansichten (letzte 30 Tage)
grant w
grant w am 30 Mär. 2022
Bearbeitet: Dave B am 30 Mär. 2022
im trying display GZ but any way i have tried to display it, just doesnt work.any suggetion on how to do it?
Z=6;
z=[1;2;3;4;5;6]
for j=1:1:Z
if (z(j,1)<4)
GZ=log(10/(4-z(j,1)))
elseif (z(j,1)==4)
GZ=Inf
else GZ=NaN
end
end

Antworten (1)

Dave B
Dave B am 30 Mär. 2022
Bearbeitet: Dave B am 30 Mär. 2022
I think this is what you're trying to produce?
z=[1;2;3;4;5;6];
Gz = nan(size(z));
Gz(z<4) = log(10./(4-z(z<4)));
Gz(z==4) = inf;
Gz
Gz = 6×1
1.2040 1.6094 2.3026 Inf NaN NaN

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by