x = [x_i:incremento:x_f];
for i=1:lenght(x)
if (x<x_1)
y=primera_definición;
else
y=segunda definición;
end
plot(x,y)
Es una forma rápida que se me ocurre. Supongamos que la función es de la forma:
f(x)= sqrt(x), si 0 < x < 5
log(x), si 5 < x <10
Quedaría:
x = [0:0.1:10];
if (x<5),
y=sqrt(x);
y=log(x);
Copyright © 2024 Q2A.MX - All rights reserved.
Answers & Comments
Verified answer
x = [x_i:incremento:x_f];
for i=1:lenght(x)
if (x<x_1)
y=primera_definición;
else
y=segunda definición;
end
end
plot(x,y)
Es una forma rápida que se me ocurre. Supongamos que la función es de la forma:
f(x)= sqrt(x), si 0 < x < 5
log(x), si 5 < x <10
Quedaría:
x = [0:0.1:10];
for i=1:lenght(x)
if (x<5),
y=sqrt(x);
else
y=log(x);
end
end
plot(x,y)