How do i fix line13; Parse error at'=': usage might be invaild Matlab syntax? why it gives error ?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Diyara Rashid
le 19 Oct 2021
Réponse apportée : Steven Lord
le 19 Oct 2021
I do not know why it gives red line under it i cant find where i did wrong ?
0 commentaires
Réponse acceptée
Steven Lord
le 19 Oct 2021
If you want to call max with two output arguments you need to combine lines 12 and 13 together and add square brackets. Use this:
[valueMax, iMax] = max(heuristicValues); % Works
instead of
valueMax,iMax
= max(heuristicValues); % DOES NOT work
Alternately add the square brackets and then use the same approach with the ellipsis that you did to break the assignment statement on lines 8 and 9 across two lines. So this would also work:
[valueMax,iMax] ...
= max(heuristicValues); % Works
My personal preference would be the first approach, the whole statement on one line, unless that results in a really long line that would require my Editor window to be very wide to see the whole line. In that case I'd probably leave the equals sign on the line with the output arguments and put the max call on its own on a second line.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!