hello, i have such a type of data per 30 days in one file.by using fgets,fscanf,str2num,strcmp i need to plot temp vs height
Ältere Kommentare anzeigen

5 Kommentare
Dyuman Joshi
am 8 Dez. 2023
Verschoben: Dyuman Joshi
am 9 Dez. 2023
Mr Thadi
am 8 Dez. 2023
Verschoben: Dyuman Joshi
am 9 Dez. 2023
Dyuman Joshi
am 8 Dez. 2023
Verschoben: Dyuman Joshi
am 9 Dez. 2023
Any particular reason why you are constrained you use those functions only, when there are better, robust functions available?
Mr Thadi
am 11 Dez. 2023
Dyuman Joshi
am 5 Feb. 2024
@Mr Thadi, did you check the answer posted below?
Antworten (1)
The following uses fscanf, fgets, str2num, and strcmp:
filename = 'file.txt';
fid = fopen(filename,'r');
counter = 0;
while counter < 2
str = fgets(fid);
if ~ischar(str)
break
end
if numel(str) > 1 && strcmp(str([1 2]),'--')
counter = counter + 1;
end
end
data = str2num(fscanf(fid,'%c'));
fclose(fid);
plot(data(:,2),data(:,3))
Kategorien
Mehr zu Data Import from MATLAB finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
