trying to integrate and differentiate a graph

so this is the code that plots my graph
clc
clear
syms t
corner=[-2 0 ;-1 1;1 1;3 4;4 2;7 0;8 0];
%plot(corner);
x=[-3 ;-1; 1; 3; 4;8];
y=[0 ,1 , -2, 4, 2,0];
figure
plot(x,y)
however cant seem to find a code that helps me integrate or differentiate the graph and plot the result as well please help

답변 (1개)

KSSV
KSSV 2021년 3월 16일

0 개 추천

clear
corner=[-2 0 ;-1 1;1 1;3 4;4 2;7 0;8 0];
%plot(corner);
x=[-3 ;-1; 1; 3; 4;8];
y=[0 ,1 , -2, 4, 2,0];
% diffrentiate
dx = diff(x) ;
dy = diff(y') ;
dydx = [0 ;dy./dx] ;
figure
plot(x,y)
hold on
plot(x,dxdy) ;

댓글 수: 6

Thank you so much sir, can you also do integration if you know how
KSSV
KSSV 2021년 3월 16일
Read about trapz for integration.
I did read and I tried using it but it showed an empty window without the graph, that’s why I came here for help
KSSV
KSSV 2021년 3월 16일
Show us what you tried....let's debug your code.
n=trapz(x,y)
Figure Plot(n)
KSSV
KSSV 2021년 3월 16일
Good.....you should note that the integration value n gives you area under the curve so it will be a value i.e. a single number. How you can plot it?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

태그

질문:

2021년 3월 16일

댓글:

2021년 3월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by