Incorporating Structure Fields into a Function as Inputs
显示 更早的评论
I'm using MATLAB (Mapping Toolbox) to create a large number of lines between different countries. Since there are so many lines, I'm trying to do this using object-oriented programming. This is the method I've written:
function transline = createlines(transline,Name,base.CapTr.val(a,b),base.EtrOut.val(:,a,b,1),base.EtrOut.val(:,b,a,1),base.EtrIn.val(:,a,b,1),base.EtrIn.val(:,b,a,1),... coords(c,2),coords(c,1),coords(d,2),coords(d,1))
where base is a struct and I intend to substitute different values for 'a' and 'b', e.g., base.CapTr.val(3,4) and create new objects.
The problem is I can't include base.CapTr.val(a,b) and the subsequent entries as inputs to the function because MATLAB declares the '.' to be an unexpected operator.
So, can you please tell me how I can add varying values of base.CapTr.val(a,b), etc. as inputs to the function?
I don't know if I've explained my problem properly, but I hope it's clear.
Thank you.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Naming Conventions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!