Problem with Graphs with MATLAB

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

 采纳的回答

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 个评论

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.

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by