for loop in case of squre bracket in matlab

4 visualizzazioni (ultimi 30 giorni)
I studied a code related to my work in which there used a for given
for jcyc=3:3:57;
[ddx, cycl_ind(jcyc)]=min(abs(jcyc-time_2));
here time_2=1× square bracket the function of ddx and cycl_ind(jcyc) is not clear to me.I mean on the left side for which purpose the square bracket and inside it ddx, cycl_ind(jcyc) is used.?
  2 Commenti
Safi ullah
Safi ullah il 24 Feb 2017
@Stephen Cobeldick thanks I studied the link and it is helpful for me

Accedi per commentare.

Risposta accettata

Image Analyst
Image Analyst il 24 Feb 2017
min() returns, or can return two outputs. If you accept more than one of the outputs, you need to group all the outputs together with brackets, otherwise it would be interpreted as two separate lines of code on the same line (you can put multiple commands on the same line if you separate them with commas).
The documentation says the first variable is the min value, and the second variable is the index where the min occurs.

Più risposte (0)


Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by