i get this error "attempting to load ybus script as a function"

i have added the ybus.m in the command window byt when i try to run the fuction it gives an error message "attempting to load script as a function"

2 Comments

@Adegoke Williams - are you referring to the code from the File Exchange found here? Please clarify what you mean by "added the ybus.m in the command window" and show how you are "running the function". Also, please copy and paste the full error message to this post.
Thanks Geoff, its Exactly that file, i actually trried so many files but got the sa error message. I used the addpath ybus on the command window to add the path to the directory. I tried to run the ybus(z) found in the Power Systems Analysis Textbook , Saadat . When i try to run the ybus(z) either on command window oR LiVESCRIPT, i get the error "Attempt to load ybus script as a function.
>> z = [0, 1, 0, 1.0; 0, 2, 0, 0.8; 1, 2, 0, 0.4; 1, 3, 0, 0.2; 2, 3, 0, 0.2; 3, 4, 0, 0.08]
Y = ybus(z)
z =
0 1.0000 0 1.0000
0 2.0000 0 0.8000
1.0000 2.0000 0 0.4000
1.0000 3.0000 0 0.2000
2.0000 3.0000 0 0.2000
3.0000 4.0000 0 0.0800
Cannot find an exact (case-sensitive) match for 'ybus'
The closest match is: Ybus in C:\Program Files\Polyspace\R2020a\bin\ybus\Ybus.
Did you mean:
>> Y = Ybus(z)
Attempt to execute SCRIPT Ybus as a function:
C:\Program Files\Polyspace\R2020a\bin\ybus\Ybus.m

Sign in to comment.

 Accepted Answer

Not sure what you are doing, but works fine for me.
z = [0, 1, 0, 1.0; 0, 2, 0, 0.8; 1, 2, 0, 0.4; 1, 3, 0, 0.2; 2, 3, 0, 0.2; 3, 4, 0, 0.08];
y=Ybus(z)
y =
0.0000 - 8.5000i 0.0000 + 2.5000i 0.0000 + 5.0000i 0.0000 + 0.0000i 0.0000 + 2.5000i 0.0000 - 8.7500i 0.0000 + 5.0000i 0.0000 + 0.0000i 0.0000 + 5.0000i 0.0000 + 5.0000i 0.0000 -22.5000i 0.0000 +12.5000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 +12.5000i 0.0000 -12.5000i
function[Ybus] = Ybus(zdata)
nl=zdata(:,1); nr=zdata(:,2); R=zdata(:,3); X=zdata(:,4);
nbr=length(zdata(:,1)); nbus = max(max(nl), max(nr));
Z = R + j*X; %branch impedance
y= ones(nbr,1)./Z; %branch admittance
Ybus=zeros(nbus,nbus); % initialize Ybus to zero
for k = 1:nbr; % formation of the off diagonal elements
if nl(k) > 0 & nr(k) > 0
Ybus(nl(k),nr(k)) = Ybus(nl(k),nr(k)) - y(k);
Ybus(nr(k),nl(k)) = Ybus(nl(k),nr(k));
end
end
for n = 1:nbus % formation of the diagonal elements
for k = 1:nbr
if nl(k) == n | nr(k) == n
Ybus(n,n) = Ybus(n,n) + y(k);
else, end
end
end
end

6 Comments

Thanks so much .
I clicked the the "convert to function" when i right click to get the answer .
However, when i click "copy output" and paste it on the command window i get the following with an error:
Secondly, how do i use the Ybus function another time? do i i have to always copy your above solution then convert to a function ?
zdata = 6×4
0 1.0000 0 1.0000
0 2.0000 0 0.8000
1.0000 2.0000 0 0.4000
1.0000 3.0000 0 0.2000
2.0000 3.0000 0 0.2000
3.0000 4.0000 0 0.0800
y = 4×4 complex
0.0000 - 8.5000i 0.0000 + 2.5000i 0.0000 + 5.0000i 0.0000 + 0.0000i
0.0000 + 2.5000i 0.0000 - 8.7500i 0.0000 + 5.0000i 0.0000 + 0.0000i
0.0000 + 5.0000i 0.0000 + 5.0000i 0.0000 -22.5000i 0.0000 +12.5000i
0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 +12.5000i 0.0000 -12.5000i
zdata = 6×4
Error: Invalid text character. Check for unsupported symbol, invisible character, or
pasting of non-ASCII characters.
Click on new, then function. Paste and above function in and save. You should now be able to execute the function from the command line whenever you want with as many different inputs as you want.
y=Ybus(z);%with z defined as above or whatever you want as input.
Thank you so much . However u dint answer y I still get that error message .
What is the problem, the below executes just fine.
zdata = [0, 1, 0, 1.0; 0, 2, 0, 0.8; 1, 2, 0, 0.4; 1, 3, 0, 0.2; 2, 3, 0, 0.2; 3, 4, 0, 0.08]
zdata = 6×4
0 1.0000 0 1.0000 0 2.0000 0 0.8000 1.0000 2.0000 0 0.4000 1.0000 3.0000 0 0.2000 2.0000 3.0000 0 0.2000 3.0000 4.0000 0 0.0800
y=Ybus(zdata)
y =
0.0000 - 8.5000i 0.0000 + 2.5000i 0.0000 + 5.0000i 0.0000 + 0.0000i 0.0000 + 2.5000i 0.0000 - 8.7500i 0.0000 + 5.0000i 0.0000 + 0.0000i 0.0000 + 5.0000i 0.0000 + 5.0000i 0.0000 -22.5000i 0.0000 +12.5000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 +12.5000i 0.0000 -12.5000i
function[Ybus] = Ybus(zdata)
nl=zdata(:,1); nr=zdata(:,2); R=zdata(:,3); X=zdata(:,4);
nbr=length(zdata(:,1)); nbus = max(max(nl), max(nr));
Z = R + j*X; %branch impedance
y= ones(nbr,1)./Z; %branch admittance
Ybus=zeros(nbus,nbus); % initialize Ybus to zero
for k = 1:nbr; % formation of the off diagonal elements
if nl(k) > 0 & nr(k) > 0
Ybus(nl(k),nr(k)) = Ybus(nl(k),nr(k)) - y(k);
Ybus(nr(k),nl(k)) = Ybus(nl(k),nr(k));
end
end
for n = 1:nbus % formation of the diagonal elements
for k = 1:nbr
if nl(k) == n | nr(k) == n
Ybus(n,n) = Ybus(n,n) + y(k);
else, end
end
end
end
Thanks so so much . It works perfectly.
Can you help me to find Y bus admittance matrix for the following "z=[
0 1 0 0.0608 %GEN 1: From ground to bus 1
0 2 0 0.1198 %GEN 2: From ground to bus 2
0 3 0 0.1813 %GEN 3: From ground to bus 3
0 5 0.6841 0.2737 % Transmission line from ground to bus 5
0 6 1.0262 0.3421 % Transmission line from ground to bus 6
0 8 0.9196 0.3219 % Transmission line from ground to bus 8
1 4 0 0.0576 % Transformer from bus 1 to bus 4
2 7 0 0.0625 % Transformer from bus 2 to bus 7
3 9 0 0.0586 % Transformer from bus 3 to bus 9
4 5 0.101 0.085 % Transmission line from bus 4 to bus 5
4 6 0.017 0.092 % Transmission line from bus 4 to bus 6
5 7 0.032 0.161 % Transmission line from bus 5 to bus 7
6 9 0.039 0.170 % Transmission line from bus 6 to bus 9
7 8 0.0085 0.072 % Transmission line from bus 7 to bus 8
8 9 0.0119 0.1008 % Transmission line from bus 8 to bus 9
0 4 0 -1/(0.088+0.079) % Shunt capacitance at bus 4
0 5 0 -1/(0.088+0.153) % Shunt capacitance at bus 5
0 6 0 -1/(0.079+0.179) % Shunt capacitance at bus 6
0 7 0 -1/(0.153+0.0745) % Shunt capacitance at bus 7
0 8 0 -1/(0.0745+0.1045)% Shunt capacitance at bus 8
0 9 0 -1/(0.1045+0.179) % Shunt capacitance at bus 9
]
y=Ybus(zdata)
"

Sign in to comment.

More Answers (0)

Categories

Find more on RF Toolbox in Help Center and File Exchange

Products

Release

R2020a

Community Treasure Hunt

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

Start Hunting!