【问题标题】:matlab Conversion to double from cell is not possible error messagematlab 从单元格转换为双精度是不可能的错误消息
【发布时间】:2013-07-02 22:18:33
【问题描述】:

这是我的代码:

%% 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)

我收到的错误消息是:

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

Evergladesprecipushdcn 中的错误(第 28 行) 情节(datenums,everglades_precip_data)

请帮忙!

【问题讨论】:

    标签: matlab plot message


    【解决方案1】:

    你可以用这个来解决它:

    plot(datenums,[everglades_precip_data{:}]);
    

    或者这个:

    plot(datenums,cell2mat(everglades_precip_data));
    

    【讨论】:

    • 非常感谢!我已经这样做了 2 天,第一行就成功了!谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-08
    • 2014-07-28
    • 2014-08-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多