Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

problem with for loop and if statement

2 visualizaciones (últimos 30 días)
abbas hasan
abbas hasan el 6 de Dic. de 2012
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
I'm trying to write code that distributes small parts possess certain conditions within a specific distance also owns certain conditions,To clarify the situation more I have 11 a small part (100,500,400,300,200,500,400,300,500,400,500)Possesses the following conditions for each small part respectively (0,0.313,0.349,0.425,0.566,0.585,0.632,0.741,0.755,0.826,0.887). i put the small part in file type mat named pitch and condition in file type mat named phase. And that distance is 6000 and owns the following conditions are represented by linspace(0,1,60), i put the condition in file type mat named PHASE the distribution is subject to the following conditions and distance represent by vector under mat file named DISTANCE first determined the distance empty according to this condition by find the index of distance have value of PHASE > (0.313/2)and after this distance we put small part (500), after this we start distribute all small part according to this condition , if abs(the value PHASE at the part distance equivalent (distance empty +500) - 0.313)> abs(the value PHASE at the part distance equivalent (distance empty +500)-0.349) we put the third small part value i.e 400 or if abs(the value PHASE at the part distance equivalent (distance empty +500) - 0.313)<= abs(the value PHASE at the part distance equivalent (distance empty +500)-0.349) we put the second value i.e 500, and we continue with all small part to full the all distance, the part of code work put thr other not work if true % code for ii=1:61 for j=1:11 index=find(PHASE>phase(2)/2,1); k=index ; pitch=DISTANCE(k)
pitch1=Pitch(2) ;
end
end
for j=2:11
if abs(PHASE(pitch/100)-phase(j))> abs(PHASE(pitch/100)-phase(j+1))
pitch2=Pitch(j+1) ;
else
pitch2=Pitch(k) ;
end
end
end
the problem with second part of code
thanks for help
  1 comentario
Jan
Jan el 6 de Dic. de 2012
@abbas: The question and the code are hard to read. Perhaps it is helpful, if you rephrase the question much shorter.
It is confusing, that you use the names "Pitch", "pitch", "pitch1" (which is set to "Pitch(2)") and "pitch2" (which is set repeatedly to Pitch(k) while k is not defined here).

Respuestas (0)

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by