I am very new to MATLAB, and am trying to plot a simple graph. I want MATLAB to integrate a function between 0 and an variable upper limit, and then plot the upper limit and value of integral on a graph. The programme works - I can see it generating the answers, but for some reason the graph doesn't plot. My very simple code is:
syms a f x y z
for x=0:0.1:1
func=a./(a.*0.3 + 8*10^-5 + (a.^4).*0.7)^0.5;
y=double(int(func,0,x))
plot(x, y,'r')
hold on
end
Obviously I am doing something wring, but cannot see what. Any help is gratefully received!
Mike

 Réponse acceptée

KSSV
KSSV le 4 Juil 2016

0 votes

syms a f x y z
x = 0:0.1:1 ; % x values
y = zeros(size(x)) ; % initialize y values
for i = 1:length(x) % loop for each x
func=a./(a.*0.3 + 8*10^-5 + (a.^4).*0.7)^0.5;
y(i) =double(int(func,0,x(i))) ;
end
plot(x, y,'r')

1 commentaire

mike halls
mike halls le 4 Juil 2016
Thanks very much for the very quick answer. I've made the changes, and get a graph. I can see what my error was. Thanks again.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by