how to display/table numbers and letters

3 visualizaciones (últimos 30 días)
grant w
grant w el 30 de Mzo. de 2022
Editada: Dave B el 30 de Mzo. de 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

Respuestas (1)

Dave B
Dave B el 30 de Mzo. de 2022
Editada: Dave B el 30 de Mzo. de 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

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by