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
조회 수: 1 (최근 30일)
이전 댓글 표시
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1563459/image.png)
댓글 수: 5
답변 (1개)
Voss
2023년 12월 11일
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))
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Preprocessing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!