s=tf('s'); pt2 = s/((s+0.1)*(s+4)); SYS = ss(pt2); A = SYS.A; B = SYS.B; C = SYS.C; D = SYS.D;
I created a linspaced timevector t_i that is equally distributed over all my discrete points. To make it easier to read I extracted some values of the real data:
% ax = traj.ax(1:10); % you can use this vector of accelerations if you want ax = [-0.7412; -0.749 ;-0.7525;-0.7508;-0.7443;-0.7331;-0.7178;-0.699;-0.6779;-0.6540]; t_i = linspace(1, 5, 10); h = diff(t_i(1:2)); % calc step size x = t_i(1) : h : t_i(end); % the range of x - not sure about this y = zeros(length(x),2); % allocate the result y u= ax; %make clear that ax is the input
Now I want to solve Eulers method as state space model:
for i=1:10-1 dx = A*x(i) + B*u(i); x_k1 = x_k + dx*h; %x_k1 is x_k+1 x_k = x_k1; % y should be a scalar output in my case, since I want to get weighted accelerations as output - but I can only compile if I put the (i,:) right now. y(i,:) = C*x_k; end
x_k = [0;0];
for i=1:N dx = A*x_k + B*u(i); x_k1 = x_k + dx*h; y(i) = C*x_k1; x_k = x_k1; end
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.