fid=fopen('filename.txt'); %opening the file
while ~feof(fid) %reading up to end of the file
tline = fgetl(fid); %reading line by line
if strcmp(tline, 'Node Number') %finding the line containing " Node Number"
break %stop reading if the "Node Number" was detected
end
end
Nnum =transpose(fscanf(fid,'%d ' , [3 Inf])) %reading the lines after the line which we were stop
% reading would stop as soon
% as the format of reading
% doesn't match anymore
while ~feof(fid) %continuing reading line by line again
tline = fgetl(fid);
if strcmp(tline, 'coordinates:')%stop when the line "coordinates"
was detected
break
end
end
Coordinate =transpose(fscanf(fid,'%d ' , [2 Inf])) %reading lines after line
"coordinate"
Можете ли вы быть немного понятнее о формате файла? Являются ли строки «Узловой номер» и «Координируют:» частью файла или у вас есть два отдельных файла? Существуют ли пробелы между строками, содержащими числа? –
Привет, Прежде всего, спасибо за внимание. Все они находятся в одном файле, и между цифрами нет пустой строки. На самом деле моя проблема была как-то решена. Код, который я написал, был этим. У вас есть лучшие идеи ??? –