how to integrate a graph

조회 수: 1 (최근 30일)
MSP
MSP 2017년 3월 29일
답변: KSSV 2017년 3월 30일
A function is given for a definite interval. Infact exact problem coding is not required.The solution must be general.
  1. f(x)=x^2;0<x<5
  2. f(x)=x;5<x<8
Now how to integrate this and plot this I came up with
syms x
c=int(x^2)
then using heaviside function I could plot e.g c.*heaviside(t)-c.*heaviside(t-5);first part
But how do you convert the sym to matlab variable again
Help is higlhy appreciated

채택된 답변

KSSV
KSSV 2017년 3월 30일
syms x
f = x^2 ;
% integration
c = int(f) ;
% plot
xx = linspace(0,5) ;
plot(xx,double(subs(c,xx)))

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by