how to display/table numbers and letters

3 次查看(过去 30 天)
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

回答(1 个)

Dave B
Dave B 2022-3-30
编辑:Dave B 2022-3-30
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

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by