Hey guys,
I'm new to matlab and i need to write a code for my homework problem and i need help from u guys. Thank u.
So basically I have P equal to different function with variable t when t is in different range.
P = 10*t/t1 when t<t1
= 10 when t1<= t <2*t1
= -10*t/t1+30 when 2*t1<= t <3*t1
= 0 when 3*t1<= t
Note: t1 will act as a constant and give a vector of P(t) with every different value of t1.
For example when t1=5, it will give a vector of P(t); and when t1=10, it will give another vector of P(t).
Then I want to use P to compute U and Udot values.
Please help me out.
%Plotting P:
t = [0:0.005:15.01];
j = 1:1000;
t1= [0.005:0.005:5]; %varying t1
P = ...
(Po*t/t1(i) ) .* (t < t1(i) ) + ...
(Po ) .* (t1(i) <= t & t < 2*t1(i) ) + ...
(-Po*t/t1(i) + 30 ) .* (2*t1(i)<= t & t < 3*t1(i)) + ...
(0 ) .* (3*t1(i) >= 15 );
i=1:1:3001;
%IV.Computing U and Udot values:
U(1)=0;
Udot(1)=0;
for i=1:1:3001
U(i+1)=A*U(i)+B*Udot(i)+C*P(i)+D*P(i+1);
Udot(i+1)=Adot*U(i)+Bdot*Udot(i)+Cdot*P(i)+Ddot*P(i+1);
end
Thanks a lot.