Integration with variable limit

Hope you all are fit and sailing the storm perfectly.
I need help in writing a MATLAB code for the problem attached herewith .
I shall be thankful to you.
Thank you,
Vivek Sharma

7 Comments

What have you attempted for your home work?

I tried the attached code but got error. I also used syms but again error

Copy and paste code here...
close all;
clear all;
clc;
Initialization of All Values
T_1=576;
V=34
x=0.01
c=13.03;
p=19.93;
m=4; % This is the impact
T_equ=zeros(1,m);
E=zeros(1,m);
V_T=zeros(1,m);
T_2=zeros(1,m);
T_2(1)=439;
for i=1:m
T_equ(i)=(T_1+T_2(i))/2;
V_T(i)=V*(integral2(@T x,21,T_equ(i),311,T_eq(i)));
E(i)=c*p*T_equ(i)*V_T(i)/23.5;
T_2(i+1)=T_equ(i);
end
T_equ
E
close all;
clear all;
clc;
%%Initialization of All Values
T_1=576;
V=34
x=0.01
c=13.03;
p=19.93;
m=4; % This is the impact
T_equ=zeros(1,m);
E=zeros(1,m);
V_T=zeros(1,m);
T_2=zeros(1,m);
T_2(1)=439;
for i=1:m
T_equ(i)=(T_1+T_2(i))/2;
syms T_2(i) T_eq(i)
f=x;
T_2min=439;
T_2max=T_2(i);
T_eqmin=507.5;
T_eqmax=T_eq(i);
int(f,T_2(i),T_2min, T_2max); % integration dt
V_T(i)=V*(int(int(f,T_2(i),T_2min, T_2max),T_eq(i),T_eqmin,T_eqmax)); % double integration
%V_T(i)=V*(integral2(@T x,21,T_equ(i),311,T_eq(i)));
E(i)=c*p*T_equ(i)*V_T(i)/23.5;
T_2(i+1)=T_equ(i);
end
T_equ
E
I do not see any 2D integration in the pdf? I only see simple integrals of x*dt for t ranges
Yes sir, its simple integral x*dt And the range of t is coming from iteration.
It is my try, as i said i am new bee for MATLAB.
Please any help!

Sign in to comment.

Answers (1)

x=0.01
That x is numeric
for i=1:m
That assigns i as a numeric variable.
T_equ(i)=(T_1+T_2(i))/2;
That assigns to T_equ() indexed at the numeric variable i
syms T_2(i) T_eq(i)
That declares that T_2 and T_eq are symbolic functions with argument i . This will not be the numeric i : this will reassign i to be an (unresolved) symbolic variable. The line there is equivalent to
i = sym('i');
T_2 = symfun('T_2(i)', i);
T_equ = symfun('T)equ(i)', i);
Notice that the numeric i is gone after this.
f=x;
x is numeric, so f will be numeric
T_2max=T_2(i);
That will invoke the symbolic function T_2 with parameter i (which is symbolic now). The result will be the unresolved T_2(i) except it will not be a symbolic function that is returned.
int(f,T_2(i),T_2min, T_2max);
f will be numeric. int() is not defined for a numeric first parameter.
If you were to use
int(sym(f),T_2(i),T_2min, T_2max);
then you would be set up to try to integrate the symbolic value 1/100 with respect to the variable T_2(i) with particular lower and upper bound. But T_2(i) is the symbolic function call T_2(i) rather than being a simple variable, and int() does not permit integrating with respect to a function call.
I do not know why you are going through all that trouble?
syms t T T__2
int(sym(x), t, T__2, T)

Categories

Find more on Programming in Help Center and File Exchange

Products

Release

R2020b

Asked:

on 16 Jun 2021

Commented:

on 16 Jun 2021

Community Treasure Hunt

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

Start Hunting!