Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
I want to store the matrices that are obtained from the loop each time.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
No matter how many times I try to store the matrices obtained at the end of the largest loop (i=1:m-1), it always ends up with a size mismatch error. Please Help!
q=input('Enter the q matrix:');
qd=input('Enter the maximum speed:');
m= size(q,1);
for i=1:m-1
q_current(i,:)=q(i,:);
q_next(i,:)=q(i+1,:);
for j=1:3
t(i,j)=(q_next(i,j)-q_current(i,j))/qd(j);
end
tmax(i)=max(t(i,:));
for j=1:3
qd_mod(i,j)=(q_next(i,j)-q_current(i,j))/tmax(i);
step_size(i,j)=0.001*qd_mod(i,j);
end
tra(:,:,i) = LinTra(q_current(i,:), q_next(i,:), step_size(i,:));
//This is where the mismatch problem arises. I want to store each matrix computed by LinTra() to the 3-dimensional matrix "tra". PLEASE HELP!!
end
The function LinTra is as follows:
function tra = LinTra(q_current, q_next, step_size)
q_step=q_current;
n=0;
while q_step<q_next
q_step=q_step+step_size;
n=n+1;
tra(n,:)=q_step;
end
for i=1:3
if tra(n,i)>q_next(i)
tra(n,i)=q_next(i);
end
end
end
0 Kommentare
Antworten (1)
KALYAN ACHARJYA
am 23 Mär. 2019
Bearbeitet: KALYAN ACHARJYA
am 23 Mär. 2019
q=input('Enter the q matrix:');
qd=input('Enter the maximum speed:');
m=size(q,1);
for i=1:m-1
q_current(i,:)=q(i,:);
q_next(i,:)=q(i+1,:);
for j=1:3
t(i,j)=(q_next(i,j)-q_current(i,j))/qd; % Here no qd(j), as qd defined as scalar
end
tmax(i)=max(t(i,:));
for j=1:3
qd_mod(i,j)=(q_next(i,j)-q_current(i,j))./tmax(i);
step_size(i,j)=0.001*qd_mod(i,j);
end
tra(:,:,i)=LinTra(q_current(i,:),q_next(i,:),step_size(i,:));
end
%Please note I didnot check the logic of the code
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!