How do you generate an integration plot on matlab?

12 次查看(过去 30 天)
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