how to display/table numbers and letters

1 view (last 30 days)
grant w
grant w on 30 Mar 2022
Edited: Dave B on 30 Mar 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

Answers (1)

Dave B
Dave B on 30 Mar 2022
Edited: Dave B on 30 Mar 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

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!