name value pairs assignment help
Ältere Kommentare anzeigen
i have to write a function having variable number of input arguments. They should come in pairs (e.g name and its value). The function should return single array and if no arguments or with odd inputs or if name is not char type, It returns an empty cell.
PS: for name value pairs here, it consists of a name(char type) and a value that can be of any data type.
Antworten (1)
Walter Roberson
am 9 Okt. 2020
0 Stimmen
you can test nargin for being odd. You can use varargin and cellfun @ischar every second entry of varargin
3 Kommentare
Mech Saints
am 11 Okt. 2020
Walter Roberson
am 11 Okt. 2020
Bearbeitet: Walter Roberson
am 11 Okt. 2020
Have you been successful in writing code to test whether a number is odd?
Have you been successful in writing a simple function that takes at least one argument?
Have you been successful in selecting every second entry in an array?
Note: varargin can only be used inside a function, not in a script.
Mech Saints
am 11 Okt. 2020
Kategorien
Mehr zu Data Type Identification finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!