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

 採用された回答

KSSV
KSSV 2016 年 7 月 4 日

0 投票

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 件のコメント

mike halls
mike halls 2016 年 7 月 4 日
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 Exchange2-D and 3-D Plots についてさらに検索

タグ

質問済み:

2016 年 7 月 4 日

コメント済み:

2016 年 7 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by