Inductance of a Transmission Line

4 views (last 30 days)
So, I'm supposed to create a function to calculate the total inductance when given the variables. This is what I have so far:
% Script file: myinductance.m
%
% Purpose:
% This program calculates the total inductance of a transmission line as
% a function of its length in kilometers, the spacing between the two
% conductors, and the diameter of each conductor.
% Known variables:
% D is the distance bewtween two conductors = 1.5 m
% r is the radius of each conductor = 2 cm
% Constant for permeability of free space:
mu0 = {4.*pi.*1e-7};
% The function of the inductance per meter of a single-phase two-wire
% transmission line is:
function inductance = myind(D, r, mu0)
inductance = (mu0./pi).*((1./4)+log(D./r));
end
It's not recognizing the name of the function (the "myind") and I'm not even sure where to go from here. ://
This is exercise 6.10 (p. 276) in "The Essentials of Matlab Programming" - Stephen J. Chapman.
  2 Comments
Star Strider
Star Strider on 26 Mar 2021
How are you calling it?
Sophia Bonifant
Sophia Bonifant on 26 Mar 2021
myind (1.5, 2, mu0)
It's been saying my function "might be unused" and I don't know to fix it. I know it recognizes as a local function, but i also don't know what that is doing to my function.

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 26 Mar 2021
The error I get is:
Operator './' is not supported for operands of type 'cell'.
because of:
mu0 = {4.*pi.*1e-7};
Since there is no need to create it as a cell array, removing the curly braces:
mu0 = 4.*pi.*1e-7;
and running:
% Script file: myinductance.m
%
% Purpose:
% This program calculates the total inductance of a transmission line as
% a function of its length in kilometers, the spacing between the two
% conductors, and the diameter of each conductor.
% Known variables:
% D is the distance bewtween two conductors = 1.5 m
% r is the radius of each conductor = 2 cm
% Constant for permeability of free space:
mu0 = 4.*pi.*1e-7;
% The function of the inductance per meter of a single-phase two-wire
% transmission line is:
Inductance = myind (1.5, 2, mu0)
function inductance = myind(D, r, mu0)
inductance = (mu0./pi).*((1./4)+log(D./r));
end
from the Command Window after saving it to my MATLAB path as ‘myinductance.m’ produces:
Inductance =
-15.0728e-009
since in R2020a (and several previous releases/versions), functions at the end of script files are allowed.
Problem solved?
.
  2 Comments
Sophia Bonifant
Sophia Bonifant on 26 Mar 2021
I think so! Thank you so much :))
Star Strider
Star Strider on 26 Mar 2021
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB 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!