How to integrate from t-1 to t in MatLab

4 views (last 30 days)
kim webb
kim webb on 17 Jul 2016
Commented: kim webb on 18 Jul 2016
Hello everyone. I am new to Matlab and I am taking a course that requires it. I have been able to integrate without problem up to now. I do not know how to code this so it works. I simply need the integral of x from t-1 to t and then add 2 to that and plot it. I have gotten a error for the dimensions not matching. I am not sure what I am doing wrong and would appreciate any help with this. Kind regards.
clear all
close all
clc
syms x
Ts = 0.01;
t = -10:Ts:10;
y = int(x,t,[t-1, t]);
yt = y + 2;
plot (t,yt)

Answers (2)

Azzi Abdelmalek
Azzi Abdelmalek on 17 Jul 2016
Something is missing, How x is related to t? look at this example
tt = -10:Ts:10;
syms x t t0
Ts = 0.01;
x=sin(t)
y = int(x,t,[t0-1, t0]);
yt = y + 2;
out=subs(yt,t0,tt)
plot (tt,out)
  1 Comment
kim webb
kim webb on 18 Jul 2016
Thank you sir. I will investigate the "out" part of the code. I was not familiar with this. I think I can get things laid out like I want from here. Thank you for your time and kind regards.

Sign in to comment.


Image Analyst
Image Analyst on 17 Jul 2016
Is there some equation for the x vs. t curve? Like is x a constant? Or a line or quadratic or a sine wave with respect to t? Also when they say they want the area between (t-1) and t, then probably gave you specific value for t, because the answer will depend on what that value is, as well as what the formula for the x vs. t equation is.
  1 Comment
kim webb
kim webb on 18 Jul 2016
Hello, no there is not a specific value for t because it represents time and is changing, so that I would get an output at each moment in time based on the new integration limits. I hope that makes sense. Kind regards

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!