""Unrecognized variable name 'Time'" I am getting this type of error during ploting , how I can fix this?
조회 수: 3 (최근 30일)
이전 댓글 표시
Warning: Variable names were modified to make them valid MATLAB identifiers. The original names are saved in the VariableDescriptions
property.
Error using check (line 12)
Unrecognized variable name 'Time'.
data_files_nr_mai = ls('*.csv');%list
const = 71.940; %upper_pyranometer_constant
%for jj = 1 : size(data_files_nr_mai,1);
data = readtable('KLOG0024.CSV');
time = data(:,{'Time'});
uper_p = data(:,{'Pyrn1_Avg'});
a = table2array(uper_p);
b = a .* const;
%for jj = 1 : size(data_files_nr_mai,1);
figure
%subplot(7,4,jj)
plot(time{:,:},b);
%plot(a,b);
댓글 수: 0
채택된 답변
Jeffrey Clark
2023년 2월 13일
@Ritesh, if you remove the first 2 header lines from the CSV it will work properly. There is probably an alternative to have MATLAB skip the first two lines but you would have to search the heirarcy of help for Create table from file - MATLAB readtable (mathworks.com) to see what options are needed to do so.
댓글 수: 3
Jeffrey Clark
2023년 2월 17일
@Ritesh if you will post one that works with your original code I may be able to tell you.
추가 답변 (1개)
Stephen23
2023년 2월 17일
The files are formatted slightly differently, as these screenshots show:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1298415/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1298420/image.png)
The READTABLE() documentation gives some options that specify the header size or data location, e.g.:
opt = {'VariableNamesLine',3, 'NumHeaderLines',2};
t08 = readtable('KLOG0008.csv', opt{:})
t24 = readtable('KLOG0024.csv', opt{:})
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!