How do I plot time vs. velocity with a matrix in Simulink ?
6 次查看(过去 30 天)
显示 更早的评论
Hi everyone.
I have a 1370x2 matrix where the first column is the time and second column is velocity.
I want to plot Time vs Velocity in x and y axis respectively.
Is there any block in Simulink that can help me with that ?
Thanks.
0 个评论
采纳的回答
Sam Chak
2022-5-27
In MATLAB, if a matrix M is given, then this would be:
t = M(:,1); % 1st column
V = M(:,2); % 2nd column
plot(t, V) % plotting V vs. t
However, in Simulink, it's a little complicated. Luckily, you can use a MATLAB Function block to do wonders.
Double-click the block and enter this code:
function plotfcn(u)
t = u(:,1);
V = u(:,2);
coder.extrinsic('plot')
plot(t, V, 'linewidth', 1.5)
grid on
xlabel('t')
ylabel('V')
2 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sources 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!