Using a loop and counter for parametric equations
이전 댓글 표시
I'm very new to MATLAB so I am aware this code is probably atrocious. Please speak clearly!
I have an equation for calculating wave power density (E) in an ocean wave. It has three variables (H, T, and h) with different numerical ranges. (i.e. H ranges from 1 to 3, T ranges from 5 to 22, and h ranges from 5 to 6.) I want to create a FOR loop where MATLAB will plug in different numbers, with increments of 1, essentially being a parametric study. I can't find any clear videos or links on nested for loops with counters.
Ex:

채택된 답변
추가 답변 (1개)
darova
2019년 10월 18일
Preallocate array before loop
E = zeros(3-1+1,22-5+1,6-5+1);
for
%% E(H,T,h) = ...
end
댓글 수: 2
Landon Sugar
2019년 10월 18일
편집: Landon Sugar
2019년 10월 18일
darova
2019년 10월 18일
Those values are dimensions of 3D matrix. You will have 3 x 18 x 2 matrix. You want to visualize it?
카테고리
도움말 센터 및 File Exchange에서 Entering Commands에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!