Error Explanation Error: File: C.m Line: 169 Column: 5 This statement is not inside any function. (It follows the END that terminates the definition of the function "readeph".)

3 visualizaciones (últimos 30 días)
Error: File: C.m Line: 169 Column: 5
This statement is not inside any function.
(It follows the END that terminates the definition of the function
"readeph".)
I keep getting this error and I have no idea why. I've been dveloping this code and this specfic line in the code is part of the original code that was fully functional before I started working on it.
  2 comentarios
dpb
dpb el 14 de Jul. de 2020
Not possible.
You may think you didn't make any change but clearly had to have deleted or moved the extraneous end statement.
Or, you may have reverted back to the original before mucking it up, but the code posted was NOT what ran successfully.

Iniciar sesión para comentar.

Respuesta aceptada

dpb
dpb el 14 de Jul. de 2020
I edited the function for you ...starting with fixing the indention to be consistent by block...which shows when you get back to original level you've closed the last block for the function() definition prematurely.
I removed all th top comments and other preparatory work at beginning of the file to let the issues be more easily visible in a very long function file...you can reinsert that or move the edits over (or ignore them as see fit).
function [gpseph,galeph,bdseph,gloeph] = readeph(file_name) % REMOVE trailing ":"
% [gpseph,galeph,bdseph,gloeph] = readeph(file_name);
....
% Now that the file pointer is set to the first satellite ephemeris,
% read it and store the data for conversion to the standard Toolbox
% ephemeris format. Set the end of file flag (eof_flag) to zero.
eof_flag = 0; % end of file not found
eph_count = 1;
% Read in all of the data as characters. Replace the Ds with Es. Write
% the modified data out to the temp file.
[data, num_read] = fscanf(fid,'%c');
c = fprintf(fid_temp,'%c',data);
fid_temp = fopen('temp.dat','r');
nLine = zeros(1,4);
noLinesGPS = 8;
noLinesGLONASS = 4;
noLinesGALILEO = 8;
noLinesBEIDOU = 8;
idxGPS = 1;
idxGLONASS = 1;
idxGALILEO = 1;
idxBEIDOU = 1;
%while true
while ~feof(fid) % USE FEOF() instead of fake condition
txtLine = fgetl(fid_temp);
if (txtLine == -1)|isempty(txtLine), break; end % Shorten the test logic expression
% USE SWITCH CONSTRUCT INSTEAD OF COMPLICATED IF...ELSEIF...
% MORE THAN LIKELY THE MULTIPLE VARIABLES HERE CAN BE HANDLED MORE EFFICIENTLY AND GENERICALLY
% BUT I MADE NO ATTEMPT TO TRY TO DECIPHER WHAT'S BEING DONE IN ORDER TO DO SO.
switch txtLine(1)
case 'G'
dataGPS{idxGPS} = txtLine;
for nLine = 1:noLinesGPS
txtLine = fgetl(fid_temp);
dataGPS{idxGPS} = sprintf('%s %s', dataGPS{idxGPS}, txtLine);
end
idxGPS = idxGPS + 1;
case 'R'
dataGLONASS{idxGLONASS} = txtLine;
for nLine = 1:noLinesGLONASS
txtLine = fgetl(fid_temp);
dataGLONASS{idxGLONASS} = sprintf('%s %s', dataGLONASS{idxGLONASS}, txtLine);
end
idxGLONASS = idxGLONASS + 1;
case 'E'
dataGALILEO{idxGALILEO} = txtLine;
for nLine = 1:noLinesGALILEO
txtLine = fgetl(fid_temp);
dataGALILEO{idxGALILEO} = sprintf('%s %s', dataGALILEO{idxGALILEO}, txtLine);
end
idxGALILEO = idxGALILEO + 1;
case 'C'
dataBEIDOU{idxBEIDOU} = txtLine;
for nLine = 1:noLinesBEIDOU
txtLine = fgetl(fid_temp);
dataBEIDOU{idxBEIDOU} = sprintf('%s %s', dataBEIDOU{idxBEIDOU}, txtLine);
end
idxBEIDOU = idxBEIDOU + 1;
end % switch txtLine(1)
end % while true
end % function readeph here
% EVERYTHING HEREAFTER IS OUTSIDE THE FUNCTION AND JUST RANDOM CODE THAT CAN"T BE THERE.
% EITHER YOU INSERTED AN EXTRA END OR YOU STARTED ADDING AT THE END OF THE FILE
% BUT IT LOOKS LIKE _PROBABLY_ THE FORMER -- PERHAPS WHILE ADDING THE IF...ELSEIF... BLOCK
% (WHICH, BTW, I TURNED INTO THE MUCH MORE LEGIBLE SWITCH CONSTRUCT
...

Más respuestas (0)

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by