How do you generate an integration plot on matlab?

2 visualizaciones (últimos 30 días)
Josh Hunt
Josh Hunt el 24 de Sept. de 2015
Respondida: Star Strider el 24 de Sept. de 2015
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 comentario
Josh Hunt
Josh Hunt el 24 de Sept. de 2015
Editada: Josh Hunt el 24 de Sept. de 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');

Iniciar sesión para comentar.

Respuestas (1)

Star Strider
Star Strider el 24 de Sept. de 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!

Translated by