Input changes in function
Mostra commenti meno recenti
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 Commento
bym
il 31 Mar 2011
Please format your code using the {} button
Risposte (2)
Matt Fig
il 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
il 1 Apr 2011
0 voti
Do not use "input" as a variable name: MATLAB can and will get it confused with the function of the same name.
Categorie
Scopri di più su Software Development in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!