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.

 채택된 답변

KSSV
KSSV 2023년 2월 27일
편집: KSSV 2023년 2월 27일

0 개 추천

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

not working yet...
I tested changing some of the values, I transposed "dt" and now everything seems to work very well and acurated, the biggest problem now is that the 60001 values ​​are appearing in the same cell, the ideal would be to arrange them along the lines of the columns in which they are allocated
KSSV
KSSV 2023년 2월 27일
I have given three options.....use the first option or second option.
Ita working as It should now, thank you very much my dear, it's almost 2AM here in Brazil and your help was generous and kind.
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.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Brenno Selli
Brenno Selli 2023년 2월 27일

0 개 추천

Trying again to code it to another sample, it's resultin in a error
Index exceeds the number of array elements. Index must not exceed 10.
Error in ESTATISTICAS_DESCRITIVAS (line 51)
tempo(:,j) = 0:dt(j):(length(road_x1)-1)*dt(j) ;
the code that I'm using right now is
dt = transpose(dx1./v); %making it a 10x1 array
m = length(dt);
n = length(verticalperf1); %verticalperf1 is na vector 1x60001, I used this vector just because sometimes the length may change and it makes the code run by the size of the verticalperf1
temp0 = zeros(m,n) ;
for j = 1:n
tempo(:,j) = 0:dt(j):(length(road_x1)-1)*dt(j) ;
end
the code results in a array (60001x10) called "tempo", its completely okay, the vallues are good and acurate, it works but the error is not allowing me to proceed, theres any way that I can solve it or just skip this error??

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

제품

릴리스

R2022b

질문:

2023년 2월 27일

답변:

2023년 2월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by