Input changes in function
Afficher commentaires plus anciens
Hi,
I have a strange problem, the input in one of my functions changes to 0 on its own.
example: File of function:
function [output]= test (input,N) input N output = size (input); end
Command: N=20; input=[1:8]; [output]= test (input,N)
Output: input=[] N=0 output = 0 0
How is this possible ? It's only one of the functions that acts this way, and even if i change the name or even make a new one with the same content it acts the same.
1 commentaire
bym
le 31 Mar 2011
Please format your code using the {} button
Réponses (2)
Matt Fig
le 31 Mar 2011
Please go back and format your code! Hightlight your pasted code, then click on the "{} Code" button.
Next, clarify what you mean by "function changes to 0 on its own." How can a function change to zero? What are you talking about?
As far as I can tell, this is your function boiled down to essentials:
function [output]= test(input,N)
output = size(input);
Now calling from the command line it seems nothing is amiss:
>> N=20; input=[1:8]; [output]= test(input,N)
output =
1 8
Walter Roberson
le 1 Avr 2011
0 votes
Do not use "input" as a variable name: MATLAB can and will get it confused with the function of the same name.
Catégories
En savoir plus sur Software Development dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!