Checking if inputs of function are numeric
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I'm relatively new to using functions, so I'm using a basic one:
function [x]= functionname(L,C,R,V,F,State)
How would I create a variable with the value of L within the function? So I can use isnumeric to make sure L is a valid input.
Also, if one of the inputs was in the form 1:10:10000, how would i create a variable of just the last figure (the 10000).
Thanks in adanvance!
0 Kommentare
Antworten (2)
the cyclist
am 10 Feb. 2013
>> tf = isnumeric(L)
will return a logical value (true/false) into the variable tf.
>> xe = x(end)
will return the last value in x, and put it into the variable xe.
0 Kommentare
Cedric
am 10 Feb. 2013
Bearbeitet: Cedric
am 10 Feb. 2013
L is a "variable within the function". It is a local variable, created when the function is called, and its value is set to be the value of the first argument listed in the call. You don't need to create a copy of L to be able to use it.
There are different ways to test L; you might want to look up for is ( is*), isa, class, size, numel in the help.
For the second point, if V for example were a vector, you could get its last element using V(end).
0 Kommentare
Siehe auch
Kategorien
Mehr zu Tables finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!