Why does the line for my graph not appear?

1 visualización (últimos 30 días)
Evan Wolff
Evan Wolff el 23 de Abr. de 2019
Respondida: Star Strider el 23 de Abr. de 2019
%the code I'm using
clc;
clear all;
close all;
syms x
f = 5./((7+x).^2);
a=0;
for b = 1:13
w(b) = int(f,[a b]);
end
plot (b,w)
hold on
axis ([1 13 0 0.5])

Respuesta aceptada

Star Strider
Star Strider el 23 de Abr. de 2019
The reason is that ‘b’ has only the value at the end of the loop, so a scalar.
Try this:
syms x
f = 5./((7+x).^2);
a=0;
b = 1:13;
for k = 1:numel(b)
w(k) = int(f,[a b(k)]);
end
plot (b,w)
hold on
axis ([1 13 0 0.5])
The solution is to define ‘b’ as a vector and refer to the elements of it in the loop, then plot against it.

Más respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by