フィルターのクリア

Only the final iteration in the loop is saved. How to save all the iterations ? * Note: all are displayed, but not saved except the last *

2 ビュー (過去 30 日間)
Xstart = 100;
Ystart = 0;
Zstart = 10;
Xend = 200;
Yend = 0;
Zend = 10;
Resolution = 100;
%% Equations
DeltaX = (Xend-Xstart)/Resolution;
DeltaY = (Yend-Ystart)/Resolution;
DeltaZ = (Zend-Zstart)/Resolution;
%% Calling Inverse Kinematics to Loop through each point of the line
for i = 1:Resolution
%% calculating actual point
X = Xstart + (DeltaX * i);
Y = Ystart + (DeltaY * i);
Z = Zstart + (DeltaZ * i);
Angles = IKin(X,Y,Z); % Calling inverse function
disp('Angles :'), disp(Angles)
writematrix(Angles,'Angles.xls')
%% calculating past points
A(1,i) = X;
B(1,i) = Y;
C(1,i) = Z;
end
%% Plot
figure
axis square
plot3(A,B,C,'bp-','lineWidth',1,'MarkerSize',3,'MarkerEdge','g','MarkerFace','y')
grid on; hold on;
plot3(Xstart,Ystart,Zstart,'g.', Xend,Yend,Zend ,'r.','MarkerSize',16)
xlabel('X Axis'); ylabel('Y Axis');zlabel('Z Axis');
title('Linear Motion')

採用された回答

Cris LaPierre
Cris LaPierre 2021 年 10 月 18 日
You need to use indexing to assign your angles to a different element of Angles each loop. Right now, you overwrite Angles every time. Basically, do the same thing you are already doing with your variables A, B, and C.
  5 件のコメント
Cris LaPierre
Cris LaPierre 2021 年 10 月 19 日
編集済み: Cris LaPierre 2021 年 10 月 19 日
You tell it whether to place the data from each loop in a column or a row. Think about your indexing.
You would likely find Ch 5 of MATLAB Onramp quite helpful.
Konard Adams
Konard Adams 2021 年 10 月 19 日
編集済み: Konard Adams 2021 年 10 月 19 日
You are appreciated. I got it, much thanks.
I have also noticed by not overwriting each step, it loops faster as well.
cheers!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by