how to increase the number in for loop as i explained below??

조회 수: 2 (최근 30일)
M.Prasanna kumar
M.Prasanna kumar 2019년 8월 20일
답변: Bhargavi Maganuru 2019년 8월 23일
for tt = 1:24
for rr = 1:24
for mm = 1:10
for nn = 1:50
[~,idx] = min(abs(time(:,1) - tof(mm,nn,rr,tt)));
voltage(mm,nn,rr,tt) =t(tt)[(idx,rr+1)]; %% here is the error
end
end
end
end
EVERY TIME WHEN tt VALUE INCREASES t(tt) should increase [t is a matrix]
if i write t1(idx,rr+1) it is working
i want to change from t1 to t2, then t3, then t4, and so on up to t24
  댓글 수: 3
M.Prasanna kumar
M.Prasanna kumar 2019년 8월 20일
sir what is meant by actual indexing?? could you please explain

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

답변 (1개)

Bhargavi Maganuru
Bhargavi Maganuru 2019년 8월 23일
You can create multidimensional array t to store t1, t2, ..t24 using “cat” function t=cat(3,t1,t2,..t24);
Now you can access t1 using t(:,:,1) and t2 using t(:,:,2) and so on.
You can modify line in your code as
voltage(mm,nn,rr,tt) =t(idx,rr+1,tt);
For more information about “cat” function, refer to the link:https://www.mathworks.com/help/matlab/ref/cat.html
Hope this helps.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by