How do you generate an integration plot on matlab?

2 ビュー (過去 30 日間)
Josh Hunt
Josh Hunt 2015 年 9 月 24 日
回答済み: Star Strider 2015 年 9 月 24 日
This is my logic:
Range = 0 - 100;
A = x-1;
B = Integrate the function (1/x^2) from 0 - 100;
C = A + B
Plot (x, C)
This is what I would like to generate a plot of; its the addition of the 2 function (C). But one of them being an integration of (1/x^2), which is being added with (x-1).
I typed something and I don't think its correct, any help is appreciated? (I am new to matlab)
  1 件のコメント
Josh Hunt
Josh Hunt 2015 年 9 月 24 日
編集済み: Josh Hunt 2015 年 9 月 24 日
My code:
X = linspace(0,100,100);
Y = (1./X.^2);
W = (X-1);
Z = (cumtrapz(X,Y));
plot(X , [W; Y; Z]);
grid on;
xlabel('x axis');
ylabel('y axis');
title('Graph');

サインインしてコメントする。

回答 (1 件)

Star Strider
Star Strider 2015 年 9 月 24 日
I’m not clear on what you want to do. See if this works:
X = linspace(0,100,100);
Y = (1./X.^2);
W = (X-1);
Z = (cumtrapz(X,Y));
plot(X , [Y; W+Z]);
grid on
xlabel('x axis')
ylabel('y axis')
title('Graph')

Community Treasure Hunt

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

Start Hunting!

Translated by