matlab转换为从单元格加倍是不可能的错误消息

1 matlab plot message

这是我的代码:

%% Load and plot precipitation data

%Read the salinity data file
fid = fopen('Everglades Precip USHDCN.csv');

%Read the salinity data file
everglades_ushcn_data = textscan(fid, '%f %*f %f %*s %f f', 'HeaderLines',2, 'Delimiter', ',');

%Close the data file
fclose(fid);

%Precip data is in the 2nd column
everglades_precip_data = everglades_ushcn_data(:, 4);

%Convert everything to a matrix
matrix_data = cell2mat(everglades_ushcn_data);

%Convert a date vector to a date number
datenums = datenum(matrix_data(:, 3:-1:1));

%Select dates
everglades_precip_year = everglades_ushcn_data{3};


%Plot surface precip data
figure
plot(datenums,everglades_precip_data)

%Convert the x axis to label date
datetick(gca)

xlabel ('Date', 'Fontsize', 14)
ylabel('Precipitation', 'Fontsize', 14)
title('Everglades Precipitation', 'Fontsize', 16)
Run Code Online (Sandbox Code Playgroud)

我收到的错误消息说:

使用绘图时出错无法从单元格转换为双精度.

误差在Evergladesprecipushdcn(第28行)情节(datenums,everglades_precip_data)

请帮忙!

Hug*_*lan 6

你可以解决这个问题:

plot(datenums,[everglades_precip_data{:}]);
Run Code Online (Sandbox Code Playgroud)

或这个:

plot(datenums,cell2mat(everglades_precip_data));
Run Code Online (Sandbox Code Playgroud)