Why does the line for my graph not appear?

%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])

 Accepted Answer

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.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!