error in using fscanf
조회 수: 1 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!