how to fix invalid first data argument

n=1;
for ii=1:0.5:9
t(n)=ii;
if ii>=0
y(n)=-3*ii.^2+5;
n=n+1;
elseif ii<0
y(n)=3*ii.^2+5;
n=n+1;
end
end
plot(t,y)

Respuestas (1)

Star Strider
Star Strider el 17 de Ag. de 2019

0 votos

Your code runs without error for me.
Note that in your code ‘ii’ is never going to be less than 0, so the entire if block is not necessary.

La pregunta está cerrada.

Preguntada:

el 17 de Ag. de 2019

Cerrada:

el 20 de Ag. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by