How do you generate an integration plot on matlab?

2 views (last 30 days)
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 Comment
Josh Hunt
Josh Hunt on 24 Sep 2015
Edited: Josh Hunt on 24 Sep 2015
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');

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 24 Sep 2015
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!