Incorporating Structure Fields into a Function as Inputs
Show older comments
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.
Accepted Answer
More Answers (0)
Categories
Find more on Naming Conventions in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!