Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
Optional Inputs & Name Value Pairs in same function
Post Body

I'm trying to use the new arguments block instead of inputparser for all of my Name/Value pairs in MATLAB now, and overall, it's working much better. However, there is one thing I could do with inputparser that I don't seem to be able to do with the argument block, but perhaps there's a way?

I want to write a function that has name/value pairs and an optional input. Using inputparser I was able to check the first element of varargin to see if it was a string (indicating the beginning of a Name/Value pair) or if it was something else (indicating it was my optional input). I'm not sure how to replicate this functionality using the argument block.

To give you an example of what I mean, using a MATLAB built in. I want to do something like how the plot command works, how you can write both

plot(Y, 'LineWidth', 2)

and

plot(X,Y, 'LineWidth', 2)

Author
Account Strength
100%
Account Age
14 years
Verified Email
Yes
Verified Flair
No
Total Karma
386,554
Link Karma
6,904
Comment Karma
370,092
Profile updated: 1 week ago
Posts updated: 9 months ago
+5

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
1 year ago