MATLAB: Operator error for loop

ephemerisMATLABoperator errorrinexrnx

I'm getting an opperator error on line 179. At this point I have a for loop where I say:
for idxGPS > 1 ;
Earlier in the code I declare idxGPS = 1. After that I have another for loop where I have data being stored in that variable so for this loop that original value of 1 should be overwritten if the previous loop processed correctly.

Best Answer

In MATLAB, a for statement must have one of the following syntaxes:
  • for variable = scalar_value : scalar_value
  • for variable = scalar_value : scalar_value : scalar_value
  • for variable = scalar_value
  • for variable = nonscalar_value
In the above, variable_name must be a simple un-indexed name.
In the above, scalar_value and nonscalar_value can be expressions that evaluate to a scalar value or nonscalar value.
Basically, the syntax is really just
for variable = expression
except that the cases with : are optimized internally.
It would thus be valid to write
for control = idxGPS > 1
As your idxGPS is scalar numeric, idxGPS > 1 would be scalar, either 0 (false) or 1 (true), and that value would be assigned to the variable for one iteration.
If you wanted to only do the body once if the condition held, and for some reason you really had an urge to use a for instead of the more straight-forward if then you could do
for control = true : idxGPS > 1
That would do the body of the loop once and only in the case that idxGPS > 1
Your code is missing a bunch of "end" statements, and appears to have improper nesting.
Your code uses otherwise which is restricted for use in a switch() statement, but you are not using a switch statement.
If you have a hankering to execute exactly one of those sections in an obscure but legal way, then
switch true
case idxGPS > 1
stuff
case idxGLONASS > 1
stuff
otherwise
stuff
end