error in using fscanf

2 Ansichten (letzte 30 Tage)
Skydriver
Skydriver am 21 Apr. 2019
I have a script like this:
%Inputing POE
file_01='POE_0.01.txt';
fid=fopen(file_01, 'r');
FileName_01=fscanf(fid,'%g %g %g', [3,Inf])';
Mag_01=FileName_01(:,1); % moment magnitude
Dist_01=FileName_01(:,2); % distance
POE_01=FileName_01(:,3); % probability of exceedance
I = (mod(1:length(Mag_01),30)==1);
Mag = Mag_01(I);
Dist = Dist_01(1:30);
POE_01 = reshape(POE_01,30,15);
marginal(1:15,1) = sum(POE_01);
file_POE = ['POE_0.5.txt','POE_0.2.txt','POE_0.1.txt','POE_0.05.txt', ...
'POE_0.02.txt','POE_0.01.txt','POE_0.005.txt'];
for i = 1:7
file_temp=file_POE(i);
fid=fopen(file_temp, 'r');
FileName_temp=fscanf(fid,'%2.2f %g %g', [3,Inf])';
POE=FileName_temp(:,3); % probability of exceedance
marginal(1:15,i)=sum(reshape(POE,30,15));
temp=sum(marginal);
hold on
plot(Mag,marginal(1:15,i)/temp(i),'DisplayName',file_POE(i))
xlabel('Magnitude (Mw)');
ylabel('Contribution to the Hazard');
end
xlim([4.5 8.8])
legend
I got a massage about :
Error using fscanf
Invalid file identifier. Use fopen to generate a valid file identifier.
Error in inputing_data (line 73)
FileName_temp=fscanf(fid,'%g %g %g', [3,Inf
Is there any one can help?

Antworten (0)

Kategorien

Mehr zu Standard File Formats finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by