""Unrecognized variable name 'Time'" I am getting this type of error during ploting , how I can fix this?

1 visualización (últimos 30 días)
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);

Respuesta aceptada

Jeffrey Clark
Jeffrey Clark el 13 de Feb. de 2023
@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 comentarios
Jeffrey Clark
Jeffrey Clark el 17 de Feb. de 2023
@Ritesh if you will post one that works with your original code I may be able to tell you.

Iniciar sesión para comentar.

Más respuestas (1)

Stephen23
Stephen23 el 17 de Feb. de 2023
The files are formatted slightly differently, as these screenshots show:
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{:})
t08 = 1440×9 table
Date Time STemp_Avg Pyrn1_Avg Pyrn2_Avg Pyrg1_Avg Pyrg2_Avg ATM_Press_Avg Tacho_Avg __________ ________ _________ _________ _________ _________ _________ _____________ _________ 21.12.2018 00:00:00 611.7 0.152 0.014 -0.24 -0.018 98539 1774.9 21.12.2018 00:01:00 611.77 0.145 0.013 -0.24 -0.018 98541 1763.7 21.12.2018 00:02:00 611.98 0.146 0.013 -0.244 -0.018 98540 1765.1 21.12.2018 00:03:00 612.43 0.151 0.014 -0.249 -0.019 98541 1764.2 21.12.2018 00:04:00 612.88 0.153 0.015 -0.252 -0.02 98540 1762.8 21.12.2018 00:05:00 613.1 0.152 0.013 -0.251 -0.022 98538 1760.4 21.12.2018 00:06:00 613.14 0.151 0.012 -0.249 -0.025 98537 1778 21.12.2018 00:07:00 613.01 0.152 0.011 -0.248 -0.023 98542 1767.4 21.12.2018 00:08:00 612.99 0.155 0.011 -0.247 -0.023 98542 1777.4 21.12.2018 00:09:00 612.98 0.154 0.012 -0.246 -0.021 98547 1760.9 21.12.2018 00:10:00 612.9 0.149 0.011 -0.243 -0.024 98548 1758.8 21.12.2018 00:11:00 612.39 0.144 0.007 -0.239 -0.023 98548 1765.1 21.12.2018 00:12:00 611.96 0.146 0.009 -0.237 -0.021 98549 1758 21.12.2018 00:13:00 611.8 0.153 0.011 -0.239 -0.02 98553 1773.9 21.12.2018 00:14:00 612 0.162 0.015 -0.244 -0.019 98557 1775 21.12.2018 00:15:00 611.93 0.166 0.015 -0.248 -0.023 98553 1780.1
t24 = readtable('KLOG0024.csv', opt{:})
t24 = 1440×9 table
Date Time STemp_Avg Pyrn1_Avg Pyrn2_Avg Pyrg1_Avg Pyrg2_Avg ATM_Press_Avg Tacho_Avg __________ ________ _________ _________ _________ _________ _________ _____________ _________ 06.01.2019 00:00:00 570.25 0.349 0.054 -0.906 -0.113 96863 1768.7 06.01.2019 00:01:00 570.24 0.35 0.055 -0.905 -0.112 96862 1765.8 06.01.2019 00:02:00 570.26 0.353 0.057 -0.904 -0.11 96861 1770.3 06.01.2019 00:03:00 570.26 0.356 0.058 -0.904 -0.112 96863 1769.1 06.01.2019 00:04:00 570.24 0.356 0.055 -0.905 -0.114 96865 1762.1 06.01.2019 00:05:00 569.8 0.357 0.055 -0.903 -0.112 96864 1770.6 06.01.2019 00:06:00 569.65 0.358 0.055 -0.903 -0.111 96867 1770.8 06.01.2019 00:07:00 569.27 0.36 0.055 -0.901 -0.112 96867 1769.1 06.01.2019 00:08:00 568.77 0.36 0.054 -0.9 -0.11 96867 1758.5 06.01.2019 00:09:00 568.43 0.362 0.056 -0.899 -0.11 96867 1773.2 06.01.2019 00:10:00 567.93 0.363 0.055 -0.899 -0.109 96868 1770.6 06.01.2019 00:11:00 567.82 0.366 0.057 -0.898 -0.108 96868 1754.5 06.01.2019 00:12:00 568.15 0.37 0.06 -0.899 -0.107 96867 1773 06.01.2019 00:13:00 568.46 0.372 0.061 -0.899 -0.108 96867 1763.3 06.01.2019 00:14:00 568.89 0.373 0.06 -0.899 -0.11 96867 1763.9 06.01.2019 00:15:00 568.93 0.374 0.059 -0.899 -0.109 96868 1769.3

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by