フィルターのクリア

Plotting surf figure, with 2 matrix and one vector. Position/Force over time.

2 ビュー (過去 30 日間)
Anders Mahler
Anders Mahler 2014 年 10 月 31 日
コメント済み: Star Strider 2014 年 11 月 7 日
Trying to plot the below, but am getteing a wierd looking figure shape, does anybody know why?
set(gcf,'Renderer','painters')
figure (1)
surf(MatDecendingPosition, tid,MatDecendingForce)
where "tid" is a time vector, while "MatDecendingPosition" and "MatDecendingForce" are 2 3x220 matrix. Attached the value. Best regards Anders Mahler

採用された回答

Star Strider
Star Strider 2014 年 10 月 31 日
If you want force and position as functions of time, I would use plot3 rather than surf:
figure(1)
plot3(MatDecendingPosition, MatDecendingForce, tid)
grid on
xlabel('Position')
ylabel('Force')
zlabel('Time')
The position-force plot produces an interesting surface:
figure(2)
mesh(MatDecendingPosition, MatDecendingForce)
grid on
xlabel('Position')
ylabel('Force')
Your data are discontinuous, so it will likely be impossible to produce a smooth surface over the entire range of your data.
  2 件のコメント
Anders Mahler
Anders Mahler 2014 年 11 月 7 日
Thanks, with the mesh function is a good way to get around the surf function
Star Strider
Star Strider 2014 年 11 月 7 日
My pleasure!

サインインしてコメントする。

その他の回答 (2 件)

Orion
Orion 2014 年 10 月 31 日
編集済み: Orion 2014 年 10 月 31 日
when you use surf, you want to see a surface Z according two others datas X, Y.
surf(X,Y,Z) means you will surf the matrix Z against the matrices of the same size X,Y (or the vectors X,Y), see meshgrid too convert vectors to matrices in order to surf.
Seeing your data (and your question), I think you want to do
figure;
subplot(211)
plot(tid',MatDecendingForce)
title('Force');
xlabel('time');
subplot(212)
plot(tid',MatDecendingPosition)
title('Position');
xlabel('time');
  1 件のコメント
Anders Mahler
Anders Mahler 2014 年 10 月 31 日
Thanks, but i am using it to show a force increase over time, in rehap, for injured people, so i really need it to be a 3D plot :-)

サインインしてコメントする。


Orion
Orion 2014 年 10 月 31 日
ok, so you want to use plot3 ?
figure;
Colors = {'b','r','g'};
for i=1:3
plot3(tid',MatDecendingPosition(:,i),MatDecendingForce(:,i),Colors{i});
hold on;
end
xlabel('time');
ylabel('Position');
zlabel('Force');
grid
legend('result 1','result 2','result 3')

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by