How do I change orientation of a graph?
6 views (last 30 days)
Show older comments
This is my code: %% Import data
numfiles = 7; % number of excel files
fileinfo = xlsread('Group B File Info');
d=dir('Trial*.csv');
%% Changing variables
no_of_subjects = 4;
no_repeat_trials = 3;
for i=7:numfiles % loop to import mutliple excel files
try
if d(i).bytes == 0
continue; % Skip this one file because it is empty.
end
mydata{i} = xlsread(d(i).name); % import files into mydata
catch
%disp([d(i).name ' read failed'])
end
myfilename = sprintf('Trial%02d.csv', i); % define file name
mydata = xlsread(myfilename); % import files into mydata
%% Perfrom Calculations
%%Define constant variables
a= 9.81; % acceleration
fz = mydata(:,5); %define column 5 of the data
fz = -fz; % invert the data
%%Define changing variables
fps = 0.001; % frames per second
%%Define Time
t = fps*(0:(length(fz)-1));
t= t'
%%Plot Results
figure(1)
plot (fz,t);
hold on
plot (jumph);
hold off
end
I want to plot fz against t. When I plot just fz it is fine however the axis is wrong so I need to plot it against t. When I plot against t the graph looks like show below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/162756/image.png)
I have transposed the data however this just flips to graph I need it to rotate 90 degress back to normal.
1 Comment
dpb
on 15 May 2014
Please trim your posted code down to the bare minimum--the reading portion isn't of any concern here; only your data and the plot.
First, you've plotted t vs fz in the code or something called jumph (that you don't show any definition for) versus its index. Which of these generated the actual plot you attached (if either?).
To plot against t, your plot will need be
plot(t,fz)
The definition of t you show is 0:dt:T for a given dt so the x-axis of the resulting plot will start at 0 on the left. I note you've negated your fz from the data source so it'll be inverted vertically; is that the issue? If so, "just don't do that" or if there's a reason it's negated and you want the axis to run the other direction vertically, then you can change that by
set(gca,'ydir','reverse')
If that isn't the problem, try again by editing the post but trim it significantly and be sure what you post and pictures you show are
a) complete in the pertinent areas (no undefined variable jumph, say)
b) what you show is exactly and only the result from the code posted, with editing for posting.
PS. You did, I gather solve the previous problem of selecting the data from the sequence by removing the zero block? If so, please accept the answer given there so can close the thread.
Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots 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!