Why does the line for my graph not appear?
1 view (last 30 days)
Show older comments
%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])
0 Comments
Accepted Answer
Star Strider
on 23 Apr 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.
0 Comments
More Answers (0)
See Also
Categories
Find more on Line 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!