From: Albert Lee on
I have typed example below into the Matlab Program. Unfortunately, the message that have been displayed are "??? Undefined command/function 'Guessing'.". What should I do with it? I will attached the example below at here.

%
% This is file guess0000.m
%
real_number=rand(1); %Generate a number between 0 and 1
real_number=10*real_number; %Scale the number between 0 and 10
number=ceil(real_number); %Round the number to the next highest integer.

%Ask the user to guess the number:
fprintf('I am thinking of a number between 1 and 10.\n');
guess=input('Guess a number:');

%Test the number.

if guess == number
fprintf('Congratulations - You guessed the correct number.\n');
end

if guess ~= number
fprintf('Your guess was wrong.\n');
fprintf('The number I was thinking of was %g.\n', number);
end


Thank you.
From: Wayne King on
"Albert Lee" <cheeping2003(a)gmail.com> wrote in message <hpbne8$4n5$1(a)fred.mathworks.com>...
> I have typed example below into the Matlab Program. Unfortunately, the message that have been displayed are "??? Undefined command/function 'Guessing'.". What should I do with it? I will attached the example below at here.
>
> %
> % This is file guess0000.m
> %
> real_number=rand(1); %Generate a number between 0 and 1
> real_number=10*real_number; %Scale the number between 0 and 10
> number=ceil(real_number); %Round the number to the next highest integer.
>
> %Ask the user to guess the number:
> fprintf('I am thinking of a number between 1 and 10.\n');
> guess=input('Guess a number:');
>
> %Test the number.
>
> if guess == number
> fprintf('Congratulations - You guessed the correct number.\n');
> end
>
> if guess ~= number
> fprintf('Your guess was wrong.\n');
> fprintf('The number I was thinking of was %g.\n', number);
> end
>
>
> Thank you.

Hi Albert, if you named the script guess0000.m, then you can't run the script by typing Guessing. The error message indicates that MATLAB doesn't have anything in its path called Guessing. If you want the script to be called Guessing, rename the Matlab file and make sure that it is in your path.

Wayne
 | 
Pages: 1
Prev: AR and MA processes
Next: ginput / line help