Why won't matlab recall the array ive just created in a function?
Afficher commentaires plus anciens
Hi,
I've written a function where output P is an array of numbers. Now i want to use P made in the function in another function, ie i want to recall P.
function P = poly_input(y)
% -------------------------------------------------------------------------
% If no value is entered in the beginning
% -------------------------------------------------------------------------
if (nargin ~= 1)
disp(' ');
y = input('Invalid, a single integer value must be entered: ');
while ~isscalar(y) || y ~= floor(y)
disp(' ');
y = input('Invalid, a single integer value must be entered: ');
end
end
% -------------------------------------------------------------------------
% If a decimal is entered in the beginning
% -------------------------------------------------------------------------
if ~isscalar(y) || y ~= floor(y)
while ~isscalar(y) || y ~= floor(y)
disp(' ');
y = input('Invalid, a single integer value must be entered: ');
end
end
disp(' ');
str1 = 'The polynomial will have order of ';
str2 = num2str(y);
disp([str1 str2 '.']);
% -------------------------------------------------------------------------
% Inputting the coefficients
% -------------------------------------------------------------------------
count = 0;
for orders = [0:1:y]
disp(' ')
str3 = 'What do you want the coefficient of x^';
str4 = ' to be; ';
alltogether = [str3 num2str(orders) str4];
count = count + 1;
Z(count) = input(alltogether);
end
P = int2str(Z);
P = str2num(P);
P
However, when i call for P in the command window MATLAB states that no value for P has been entered!?
Thanks
1 commentaire
Jan
le 8 Avr 2013
Please lern how to format code properly in the forum. It is a good idea to make it as easy to read as possible. Inserting an empty line after each line of code is not useful, but follow the "? help" link to learn how to use the forum interface.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Creating and Concatenating Matrices 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!