matlab导入数据,运行代码出错。

15 次查看(过去 30 天)
levagin
levagin 2023-3-30
回答: locefaa 2023-3-30
我把excel的数据转换成mat文件格式,然后出现以下问题
函数或变量 'shuju' 无法识别。
出错 MLplots (第 14 行)
G = graph(shuju(:,1), shuju(:,2));
以下是我的代码
load('shuju'); %Load data
g = graph(shuju(:,1), shuju(:,2));
lb = 0.0; %Upper and lower bounds for alpha
ub = 1.0;
[D, DD] = arrayfun(@(a) ... %Apply MLmodel to alpha values.
MLmodel(g,a, 1:10), linspace(lb,ub,11));
figure; %Plot Damage versus alpha.
plot(linspace(lb,ub,11), D, linspace(lb,ub,11), DD)
legend('D', 'D^{\prime}')
title('I. Damage versus \alpha Values (First 50 Node Failure)')
xlabel('\alpha Value')
ylabel('Damage')

采纳的回答

locefaa
locefaa 2023-3-30
我的意思是你文件能不能用load读取成功,看来是没有的,又或者是变量名并不是shuju,在load代码前面加上clear,将断点放在g = graph(shuju(:,1), shuju(:,2));查看工作区内容的方式来查看文件内容。

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by