plot difference between graphs
Show older comments
i have made the following code but do not know how to plot the difference between the two graphs, the code as it is now, plots the two lines on the same graph, but i want to plot the differnece between these two graphs and do not know how to do so. the data to be graphed needs to still ahve all the zeros removed
%position
file_name = 'GenLowpass8hz.data';
data = dlmread(file_name,'\t',0,0);
%coulmns
column_1=data(:,1); % Chan1 Biceps Raw
column_2=data(:,2); % Chan2 Wrist Extensor Raw
column_3=data(:,3); % Chan3 Filtered EMG
column_4=data(:,4); % Chan4 Ball Position (radians)
column_5=data(:,5); % Chan5 Elbow Position (rad)
%creating time vector
DataSize=size(data,1);
t= 0:(1/960): ((DataSize-1)/960);
%plot data
%remove zeros
index=find(data(:,4)>0);
idx=find(data(:,5)>0);
subplot(3,2,1)
plot(t(index),column_4(index),':ob')
xlim([0 20])
ylim([6 9.5])
hold on
plot(t(idx), column_5(idx),':xr')
hold off
legend('ball','elbow')
title('LowPass 8Hz', 'FontSize',18);
xlabel('Time (s)');
ylabel('Position (rad)');
ignore the attached image
1 Comment
Walter Roberson
on 3 Oct 2013
What do you want to have happen at the t locations for which one of the two has a value but the other does not? If you want to interpolate between adjacent values then you will need to indicate which kind of interpolation to use.
Answers (0)
Categories
Find more on Calculus 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!