Project Development: Matlab/Voice Session.

Thursday, June 17, 2010

Matlab/Voice Session.

The Content For Matlab/Voice Session.
GuessNumber.m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function GuessNumber
    disp('Generating a random number from 0 to 10');
    disp('You have 7 times to guess this number');
    disp('I will tell you if your guessed number is greater of less then the right number');
    number = ceil(rand(1,1)*10);
    count = 0;
    while(count < 5)
        temp = input('What Integer You Want to Try: ');
        if temp == number
            if count <= 1
                disp('Genieus, You got it right');
            else
                disp(['You are so smart, It is exactly ', num2str(temp)]);
            end
            break;
        else
            if temp > number
                disp(['Try some numbers smaller than ', num2str(temp)]);
            else
                disp(['Try some numbers larger than ', num2str(temp)]);
            end
            if count <=2
                disp('You still have chance to win, Good Luck');
            else
                disp([num2str(5-count), ' times left, Take care what you choose']);
            end
        end
        count = count + 1;
    end
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
LeapLeap.m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function LeapLeap
%     year = 2000;
    year = input('Type the year you want to check, e.g. 2000 : ');
    if (mod(year, 4)==0 && mod(year, 100)~=0) || mod(year, 400)==0
        disp([num2str(year), ' is a leap year']);
    else
        disp([num2str(year), ' is NOT a leap year']);
    end
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Voice Part.

1st Links.
2nd Links.
3rd Links.

No comments:

Post a Comment