hello, i have such a type of data per 30 days in one file.by using fgets,fsca​nf,str2num​,strcmp i need to plot temp vs height

5 Kommentare

Use readtable to read the data into a table and use indexing to access and thus plot the data using plot
Mr, joshi thank you. I was done by using this command thats appreciable but I need by using commands with fscanf, fgets, str2num, strcmp
Any particular reason why you are constrained you use those functions only, when there are better, robust functions available?
yes,but i need solution in this way only

Melden Sie sich an, um zu kommentieren.

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

Produkte

Gefragt:

am 8 Dez. 2023

Kommentiert:

am 5 Feb. 2024

Community Treasure Hunt

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

Start Hunting!

Translated by