could "cellfun" solve my problem?

1 次查看(过去 30 天)
maha arcc
maha arcc 2015-9-3
评论: maha arcc 2015-9-3
% Line Data for B-Bus (Shunt Admittance)Formation.
% function bbus = bbusppg,8 % Returns B-bus..
linedata = linedatas ,8;
fb = linedata(:,1);
tb = linedata(:,3);
b = linedata(:,7);
nbus = max(max(fb),max(tb)); % no. of buses...
nbranch = length(fb); % no. of branches...
bbus = zeros(nbus,nbus);
for k=1:nbranch
bbus(fb(k),tb(k)) = b(k);
bbus(tb(k),fb(k)) = bbus(fb(k),tb(k));
end
i got:
linedata =
[1] '1a' [3] '2a' [0.0024] [0.0183] [0.0264] [1]
[2] '1b' [7] '4a' [0.0540] [0.2230] [0.0246] [1]
[4] '2b' [5] '3a' [0.0470] [0.1980] [0.0219] [1]
[6] '3b' [1] '1a' [0.0346] [0.1055] [0.0215] [1]
[4] '2b' [8] '4b' [0.0024] [0.0173] [0.0345] [1]
Undefined function 'max' for input arguments of type 'cell'.
Error in bbusppg (line 9)
nbus = max(max(fb),max(tb)); % no. of buses...
if I apply "cellfun' is it work?could I apply this for columns 1,3&7 only .if yes,how? and if the answer No what can i do?!

回答(1 个)

Kelly Kearney
Kelly Kearney 2015-9-3
You just need to convert your numeric data from cell arrays to a numeric arrays:
fb = cell2mat(linedata(:,1));
tb = cell2mat(linedata(:,3));
etc...
  2 个评论
maha arcc
maha arcc 2015-9-3
can't thank you enough, I tried it and it worked :D

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Cell Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by