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')

카테고리

Help CenterFile Exchange에서 Frequency-Domain Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by