Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Help me in using loop "For and if"

1 visualizzazione (ultimi 30 giorni)
Dam Tung
Dam Tung il 17 Set 2020
Chiuso: Stephen23 il 17 Set 2020
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

Risposte (0)

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by