How to Set Specific Arg in Function
显示 更早的评论
Hi, I'm trying to use th function give at this link:
When I set the default values it works fine ie:
heatscatter(workingr, workingi,'', 'test.png');
However I would now like to add a title, but I cannot figure out how to do this. I've tried seraching for how to change/edit/give a specific argument but I can't find it. I've tried the following options but none seem to work:
heatscatter(workingr, workingi,'', 'test.png', 'title', 'testtitle');
heatscatter(workingr, workingi,'', 'test.png', 'title', testtitle);
heatscatter(workingr, workingi,'', 'test.png', title, testtitle);
I always get the error:
Nonfinite endpoints or increment for colon operator in index.
When I fill out the entire list of args as:
heatscatter(workingr, workingi,'', 'test.png','300', '10', '.', 0, 0, 'test', 'test2','title');
I can control all the parameters, except title - I get the following error:
Index exceeds the number of array elements (5).
Error in heatscatter (line 186)
title(title);
What am I doing wrong? Thanks in advance.
采纳的回答
更多回答(1 个)
Vibhav
2024-4-26
0 个投票
Since R2021a, you can use named arguments in MATLAB:
https://www.mathworks.com/help/matlab/matlab_prog/namevalue-in-function-calls.html#
1 个评论
The function the OP was calling did not use name-value inputs, only positional inputs (specifically: the 12th input). That the OP did not understand the difference was the OP's problem in the first place, so this answer just continues the confusion rather than clarifying it.
Note that name-value inputs have been suported for as long as any function has been written to parse them, certainly much earlier than 2021a (as the date of the original question and answer reminds us).
类别
在 帮助中心 和 File Exchange 中查找有关 Operators and Elementary Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!