how to set port using loop indexing instead of defining every node pair explicitly.

I have created a 3 port network in matlab. What I want to achieve is to set port of the network using setports function but I dont want to explicitly write the node pair like this:
setports(ckt,[6 0] ,[3 0] ,[2 0])
I have node array like this
port_node =
6 0
3 0
2 0
So what I want is to set ports using port_node indexing instead of explicitly assign its value. Would you please let me know how to do that?

 Accepted Answer

setports(ckt,port_node(1,:),port_node(2,:),port_node(3,:))
or
b=mat2cell(port_node,ones(size(port_node,1),1),size(port_node,2))
setports(ckt,b{:})

3 Comments

Oh sorry for little ambiguity in the question, what I mean is setting ports by doing something in loop, something like this
for i = 1:length(port_node)
setports(ckt,port_node(i,:))
end
I want to do something like this because I want my script to set ports by itself even when it is not just 3, but 4,5,6 or n ports. Hope now question makes more sense.

Sign in to comment.

More Answers (0)

Products

Release

R2020a

Community Treasure Hunt

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

Start Hunting!