[~,ant_est] = max(abs(z));

When i used this above code in my matlab version 2009a it is showing an error Expression or statement is incorrect--possibly unbalanced (, {, or [.
help me to correct it

2 Commenti

Massimo Zanetti
Massimo Zanetti il 26 Gen 2017
Modificato: Massimo Zanetti il 26 Gen 2017
Most probably the error is not related to this line of code. Please, post more details (e.g., the piece of code and the whole matlab error message, including the line at which the error is found).
James Tursa
James Tursa il 26 Gen 2017
Modificato: James Tursa il 26 Gen 2017
I.e., several lines above and below the offending line.

Accedi per commentare.

 Risposta accettata

Walter Roberson
Walter Roberson il 26 Gen 2017

1 voto

The ~ operator was not implemented until R2009b. You can replace that code with
[UnUsEdVaRiAbLe_To_IgNoRe, ant_est] = max(abs(z));
clear UnUsEdVaRiAbLe_To_IgNoRe

6 Commenti

Jan
Jan il 26 Gen 2017
I've used:
[dummy, ant_est] = max(abs(z));
and omitted the clearing usually. But this might occupy memory until the function is finished.
Kartickeyan V
Kartickeyan V il 26 Gen 2017
when i use this code the program stuck in busy mode
Walter Roberson
Walter Roberson il 26 Gen 2017
Your z might be very large. You might be running low on memory. abs(z) is going to need to make a temporary variable the same size as z, and possibly your variables are so large that you are forcing your system to swap when you do that.
Jan
Jan il 26 Gen 2017
@Kartickeyan V: That the code needs time to run has no relation to using a temporary variable to ignore the 1st output of max.
You can use the profiler to find out, which commands takes the time.
Adam
Adam il 26 Gen 2017
Don't clear the variable if time is more of an issue than memory. clear instructions take a lot of time, relatively.
Walter Roberson
Walter Roberson il 26 Gen 2017
I would be unlikely to clear the junk variable myself, unless I was short on memory. The "clear" I showed is the logical equivalent, not the practical equivalent.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by