How do I repeat the comand for another line
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Brenno Selli
am 27 Feb. 2023
Beantwortet: Brenno Selli
am 27 Feb. 2023
I need to repeat the command for 10 lines so that the array is 10x60001
The code is
dt = dx1./v;
tempo = [0:dt(:,1):(length(road_x1)-1)*dt(:,1)];
"dt" is an 1x10 array with different values on each column
"tempo" is resulting in a 1x60001 array getting only the first value from dt, I need it to get the values from all the colunms resulting in a 10x60001 array, I tryed tempo = 0:dt:(length(road_x1)-1)*dt but it didn't work either.
sorry if i wasn't clear, my english is a bit rusty.
0 Kommentare
Akzeptierte Antwort
KSSV
am 27 Feb. 2023
Bearbeitet: KSSV
am 27 Feb. 2023
dt = dx1./v; % let dt be 10x1 array
m = length(dt) ;
n = 60001 ;
temp0 = zeros(m,n) ;
for i = 1:n
tempo(:,i) = 0:dt(i):(length(road_x1)-1)*dt(i) ; % If this results into 60001
end
In the above the RHS step should result into 1x60001 array. IF not
dt = dx1./v; % let dt be 10x1 array
m = length(dt) ;
n = 60001 ;
temp0 = cell(m,1) ;
for i = 1:n
tempo{i} = 0:dt(i):(length(road_x1)-1)*dt(i) ;
end
If your target is to get only 10x60001 array.
dt = dx1./v; % let dt be 10x1 array
m = length(dt) ;
n = 60001 ;
temp0 = zeros(m,n) ;
for i = 1:n
tempo(:,i) = linspace(0,(length(road_x1)-1),n) ; % This results into 60001
end
5 Kommentare
Image Analyst
am 27 Feb. 2023
If this Answer solves your original question, then could you please click the "Accept this answer" link to award the answerer with "reputation points" for their efforts in helping you? They'd appreciate it. Thanks in advance. 🙂 Note: you can only accept one answer (so pick the best one) but you can click the "Vote" icon for as many Answers as you want. Voting for an answer will also award reputation points.
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!