For loop and if loop

1 回表示 (過去 30 日間)
Dam Tung
Dam Tung 2020 年 9 月 17 日
Hi, every one.
I have a problem of simulating the operation of a ship, in which I have used loops "For and if" for solving. I wrote in matlab and obtained results but Result is not correct. I think i did mistake with these loop. Please fix me the following code. In the picture show the scheme of this model. Many thanks
clear all;
clc;
R=300;
v=11;
zt=33;
P=77;
Q=0;
Q2=0;
q=4;
hpr=2;
hw=[1.5 1.8 2.2 2.3 2 2.3 2.4 2.5 2.7 3 1.8 1.5 1.5 1.8 2.2 2.3 2.1 2.3 2.4 2.5 2.7 3 1.8 1.5 1.5 1.8 2.2 2.3 2.1 2.3 2.4 2.5 2.7 3 1.8 1.5...
1.5 1.8 2.2 2.3 2.1 2.3 2.4 2.5 2.7 3 1.8 1.5 1.5 1.8 2.2 2.3 2.1 2.3 2.4 2.5 2.7 3 1.8 1];
t=0;
tper=R*1.6/(v*1.82)*1.1/24
tst=2;
for i=1:60
if hw(i)<hpr
t2=0
Q=q+Q
z=(i+tper)*2
else
t2=tst
Q=q+Q
z=(i+tper)*2
if (z/zt<1.1) || Q>P
t=i+tper+tper+t2
if t>30
Q1=Q
break;
end
end
end
end

回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by