Why a script doesn't work by itself and just included in another script?

1 ビュー (過去 30 日間)
gblmtc
gblmtc 2018 年 5 月 25 日
コメント済み: gblmtc 2018 年 5 月 25 日
Hi there!
I have this script :
fid = uigetfile('*.sp3');
fid=fopen(fid);
fmt=[sat repmat('%f ',1,8)];
satSP3=[];
timpSP3=[];
while ~feof(fid)
l=fgetl(fid); % read a record
if l(1) =='*' % identificare timp pozitii sateliti
[p] = sscanf(l,'%c %d %d %d %d %d %d %d %d');
[gpsW,gpsS] = civil2GPStime (p(2), p(3), p(4), p(5), p(6), p(7));
end
%extragere pozitii pentru satelit X
if strfind(l,sat)
satSP3=[satSP3; cell2mat(textscan(l,fmt,'collectoutput',1))];
timpSP3 = [timpSP3; gpsS];
end
end
satSP3 = [satSP3(:,1:3) timpSP3];
fclose(fid);
When I press RUN I get this error :
Error in date_initiale_extragere_automata (line 4)
fmt=[sat repmat('%f ',1,8)];
And I have another script which includes the first one. When I run the second script I get no error. Could you please tell me where the problem is?
That's the script #2:
sat = 'PG04';
date_initiale_extragere_automata;
load_nav_param;
for i = 1:size(satSP3,1);
X = computemany(satSP3(i,4),toe,mo,a,deltan,e,omega,cuc,cus,crc,crs,io,idot,cic,cis,omegae,odot,omegao);
%nota bene in apelarea de mai sus am luat timpul din coloana a 4-a de
%pe linia curenta din satSP3
satEFEM (i,:) = X;
end
Thanks!
  1 件のコメント
gblmtc
gblmtc 2018 年 5 月 25 日
I forgot to ask regarding the repmat('%f',1,8). I do not remember what the teacher told that it means. I do not understand the %f is cominf from. I look at the explanation regarding repmat on help but there is nothing about using the % . Thanks!

サインインしてコメントする。

採用された回答

Geoff Hayes
Geoff Hayes 2018 年 5 月 25 日
glbmtc - you haven't posted the error but I suspect the problem is that you haven't defined sat and so you are erroring on the line
fmt=[sat repmat('%f ',1,8)];
with (maybe) sat is undefined variable or function. Note how in the second script, you define sat before calling the first script
sat = 'PG04';
date_initiale_extragere_automata;
I suggest that you change your first script into a function and pass in the sat as an input parameter. See function for more details.
As for
repmat('%f ',1,8)
it is replicating the '%f; character eight times (just try running this from the command line and also checking the documentation for repmat with doc repmat).
  3 件のコメント
gblmtc
gblmtc 2018 年 5 月 25 日
Thank you Steve!
Very useful info ;). That's what I need, simple explanation to can make it clear in my mind.
Have a lovely day!

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by