% % This routine plots the response from state variable % feedback and the corresponding response with transfer functions % % final_time is the final time on the plot % tf_filename is the name of the file with the transfer function response % sv_filename is the name of the file with the corresponding state % variable feedback response % Both of these should be entered within single quotes, i.e. 'tf_data.dat', % 'sv_data.dat' function compare_tf_sv(tf_filename,sv_filename,final_time) % % data1 = importdata(tf_filename); data2 = importdata(sv_filename); % % Now extract the data we want % encoder = 1; scale = 1/2196; % convert to cm tstep1 = data1(:,encoder+1); ystep1 = data1(:,encoder+3)*scale; tstep2 = data2(:,encoder+1); ystep2 = data2(:,encoder+3)*scale; % % Now plot the two % plot(tstep1,ystep1,'-',tstep2,ystep2,':'); grid; legend('TF Controller','State Variable Controller'); title('Comparison of TF and State Variable Controllers'); ymin = min(min(ystep1),min(ystep2)); ymax = max(max(ystep1),max(ystep2)); axis([0 final_time ymin ymax]); xlabel('Time (sec)'); ylabel('cm'); % return;