Plotting data of a 3x1xn array
3 ビュー (過去 30 日間)
古いコメントを表示
Rashmil Dahanayake
2014 年 1 月 3 日
編集済み: Rashmil Dahanayake
2014 年 1 月 3 日
Hi, I saved data of a simulation in to a 3x1xn cell array.
How can I plot each 3x1 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)
2 件のコメント
Walter Roberson
2014 年 1 月 3 日
Your odq is not a 3 x 1 x n cell array: it is a 1 x n cell array that contains 3 x 1 matrices.
You have 3 values per element of t; how do you want them plotted? Do you want t on the x axis and three separate lines, one consisting of the first coordinates connected, one of the second, one of the third ?
採用された回答
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!