how do i iterate this expression and save each iterate?
Show older comments
Hello all, kindly help. I need to get the values of y for each step of z. thanks in advance.
clear
clc
t = 0.005;
delta_t = 0.005;
n = 0.5;
w = 30;
qt = 3864*t;
m = 3;
p = 30;
G = 0.05;
syms T
F1 = qt*exp(G/2*p*T)*cos(p*T);
F2 = qt* exp(G/2*p*T)*sin(p*T);
syms x t2;
z = 0:delta_t:n;
% % % ta and a change from 0 to n with delta_t step, I need to automate
% % % % this
ta = z(1);% need to automate this to change from 0 to n
a=z(1);% need to automate this to change from 0 to n
t1 = a - delta_t;
F11 = int(F1, t1, t2);
F21 = int(F2, t1, t2);
fa = (subs(F11, t2, a));
fb = (subs(F21, t2, a));
d1 = exp(-G/2*p*ta)*sin(p*ta);
d2 = exp(-G/2*p*ta)*cos(p*ta);
% % this expresion d1*fa changes with every step, for ex. for y2 it would
% be d1*(fa+fa2), for y3 it would be d1*(fa+fa2+fa3) in that order. The
% same goes with d2*fb. i need the values y1,y2,y3. d1 and d2 as ta
% changes.
y1 = double((d1*fa - d2*fb)/(m*p))
% % ****below is my next step of y. that is y2 as an example****
tb = z(2);
a2=z(2);
t12 = a2 - delta_t;
F11 = int(F1, t12, t2);
F21 = int(F2, t12, t2);
fa2 = (subs(F11, t2, a2));
fb2 = (subs(F21, t2, a2));
d12 = exp(-G/2*p*tb)*sin(p*tb);
d22 = exp(-G/2*p*tb)*cos(p*tb);
y2 = double((d12*(fa+fa2) - d22*(fb+fb2))/(m*p))
Answers (0)
Categories
Find more on Numeric Solvers in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!