MATLAB: Plotting data of a 3x1xn array

cell array plotfor loopMATLAB

Hi, I saved data of a simulation in to a 3x1xn cell array.
How can I plot each 3×1 instance Vs time. At the moment I manually saved data in to 3 separate variables in order to plot.
There could be a way to plot by extracting data straight from a n dimension cell.
refer to the comments on subplot(2,1,1)
clc;
clear all;
% Simulation settings
st=0.4; % simulation period in seconds
Ts=1e-6; % sampling period in seconds
t=0:Ts:st;
m=1;fo=50;
% initialize variables to increase simulation speed
o=zeros(1,numel(t));
d=zeros(1,numel(t));
q=zeros(1,numel(t));
for k=1:numel(t)
x=2*pi*fo*k*Ts; % theta

T= [1/2 1/2 1/2 ;... % transfer matrix
cos(x) cos(x-2*pi/3) cos(x+2*pi/3);...
sin(x) sin(x-2*pi/3) sin(x+2*pi/3)];
% 3 phase input signal
U=2/3*m*sin([x ; x- 2*pi/3 ; x+ 2*pi/3 ]);
% store values in 0dq matrix
o(k)=T(1,:)*U;
d(k)=T(2,:)*U;
q(k)=T(3,:)*U;
% odq(:,:,k)=T*U; % saving in to a cell array
end
% subplot(2,1,1);plot(t,odq); % what is the correct way plotting cell
% object defined in for loop.
subplot(2,1,1);plot(t,[o; d; q]);
y=2*pi*fo*t; % theta
U2=m*sin([y ; y- 2*pi/3 ; y+ 2*pi/3 ]);
subplot(2,1,2);plot(t,U2)

Best Answer

plot(t, horzcat(odq{:}).' )