could "cellfun" solve my problem?

조회 수: 5 (최근 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일
thanks,I'll try that
maha arcc
maha arcc 2015년 9월 3일
can't thank you enough, I tried it and it worked :D

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by