Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- q1=dlmread('D:\F19\MTE360\Lab1\Lab 1\lab1_q1a.txt')
- q1_tab= array2table(q1);
- q1_tab.Properties.VariableNames{1} = 'Time';
- q1_tab.Properties.VariableNames{2} = 'Input Voltage';
- q1_tab.Properties.VariableNames{3} = 'Output Voltage';
- findpeaks(q1(:,[3]), 'MinPeakDistance', 500, 'MinPeakHeight', 1);
- [pks, locs]=findpeaks(q1(:,[3]), 'MinPeakDistance', 500, 'MinPeakHeight', 1);
- q1_tab=table(q1_tab.Time, q1_tab.("Output Voltage"));
- q1_tab_append=q1_tab(1500:2000, :);
- %Second cycle used
- tau_v_Val= 0.6321*pks(2);
- [minDistance, indexOfMin]= min(abs(q1_tab_append.Var2-tau_v_Val));
- tau_v= q1_tab_append.Var1(indexOfMin)-1.5;
- K_v= pks(2);
- t_v=tau_v;
- open('vel_step.mdl'); % opens the model file
- sim('vel_step.mdl'); % runs the simulation
- time=ScopeData1.time; %scope data in milliseconds
- response=ScopeData1.signals.values;
- inTime=ScopeData.time;
- inVals=ScopeData.signals.values;
- theoretical=table(time, response);
- figure(2)
- subplot(2,1,1);
- plot(theoretical.time, theoretical.response)
- hold on
- plot(q1(:,[1]),q1(:,[3]))
- xlim([0 4])
- ylim([-300 300])
- legend({'Theoretical', 'Measured'})
- title('Velocity Real vs. Theoretical');
- ylabel('Velocity [mm/s]');
- xlabel('Time [s]');
- subplot(2,1,2);
- plot(inTime,inVals)
- xlim([0 4])
- ylim([-2 2])
- title('Input Voltage');
- ylabel('Voltage [V]');
- xlabel('Time [s]');
- legend({'Input'})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement