Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
how to display the largest number in command?

Subject: how to display the largest number in command?

From: apple

Date: 5 Apr, 2009 16:10:03

Message: 1 of 4

i 'm doing the program about finding the largest number between the sales. i tried doing the command. after that i tried to key-in the number, suppose to be it show the largest number but it in opposite way.. so this is my command.. can u please identified my mistake...

q = input ('enter akasyah sales= ');
r = input ('enter ariff sales= ');
s = input ('enter hafiz sales= ');
t = input ('enter wan sales= ');
u = input ('enter irfan sales= ');
v = input ('enter izzul sales= ');
w = input ('enter shahmi sales= ');
x = input ('enter faiz sales= ');
y = input ('enter azdli sales= ');
z = input ('enter yusrin sales= ');
 
if q > r
    display ('akasyah win the contest');
elseif q > s
    disp (' akasyah win the contest');
elseif q > t
    display ('akasyah win the contest');
elseif q > u
    display ('akasyah win the contest');
elseif q > v
    display ('akasyah win the contest');
elseif q > w
    display ('akasyah win the contest');
elseif q > x
    display ('akasyah win the contest');
elseif q > y
     display ('akasyah win the contest');
elseif q > z
    display ('akasyah win the contest');
elseif r > q
    display ('ariff win the contest');
elseif r > s
    display ('ariff win the contest');
elseif r > t
    display ('ariff win the contest');
elseif r > u
     display ('ariff win the contest');
elseif r > v
     display ('ariff win the contest');
elseif r > w
     display ('ariff win the contest');
elseif r > x
     display ('ariff win the contest');
elseif r > y
     display ('ariff win the contest');
elseif r > z
     display ('ariff win the contest');
elseif s > q
    display ( 'hafiz win the contest');
elseif s > r
     display ( 'hafiz win the contest');
elseif s > t
     display ( 'hafiz win the contest');
elseif s > u
     display ( 'hafiz win the contest');
elseif s > v
     display ( 'hafiz win the contest');
elseif s > u
     display ( 'hafiz win the contest');
elseif s > v
     display ( 'hafiz win the contest');
elseif s > w
     display ( 'hafiz win the contest');
elseif s > x
     display ( 'hafiz win the contest');
elseif s > y
     display ( 'hafiz win the contest');
elseif s > z
     display ( 'hafiz win the contest');
elseif t > q
    display ( 'wan win the contest');
elseif t > r
     display ( 'wan win the contest');
elseif t > s
     display ( 'wan win the contest');
elseif t > u
     display ( 'wan win the contest');
elseif t > v
     display ( 'wan win the contest');
elseif t > w
     display ( 'wan win the contest');
elseif t > x
     display ( 'wan win the contest');
elseif t > y
     display ( 'wan win the contest');
else t < z
     display ( 'wan win the contest');
 
     
 

Subject: how to display the largest number in command?

From: Wayne King

Date: 5 Apr, 2009 16:54:01

Message: 2 of 4

Hi,
Why do you want to create so many scalar variables for your input statements? You're not making use of the fact that Matlab is vectorized. You should assign the inputs to elements of an array and then you can easily find the maximum value of the array and its location and determine who had the largest sales.
hope that helps,
wayne

"apple " <Quixotic04@yahoo.com> wrote in message <gral4r$5ah$1@fred.mathworks.com>...
> i 'm doing the program about finding the largest number between the sales. i tried doing the command. after that i tried to key-in the number, suppose to be it show the largest number but it in opposite way.. so this is my command.. can u please identified my mistake...
>
> q = input ('enter akasyah sales= ');
> r = input ('enter ariff sales= ');
> s = input ('enter hafiz sales= ');
> t = input ('enter wan sales= ');
> u = input ('enter irfan sales= ');
> v = input ('enter izzul sales= ');
> w = input ('enter shahmi sales= ');
> x = input ('enter faiz sales= ');
> y = input ('enter azdli sales= ');
> z = input ('enter yusrin sales= ');
>
> if q > r
> display ('akasyah win the contest');
> elseif q > s
> disp (' akasyah win the contest');
> elseif q > t
> display ('akasyah win the contest');
> elseif q > u
> display ('akasyah win the contest');
> elseif q > v
> display ('akasyah win the contest');
> elseif q > w
> display ('akasyah win the contest');
> elseif q > x
> display ('akasyah win the contest');
> elseif q > y
> display ('akasyah win the contest');
> elseif q > z
> display ('akasyah win the contest');
> elseif r > q
> display ('ariff win the contest');
> elseif r > s
> display ('ariff win the contest');
> elseif r > t
> display ('ariff win the contest');
> elseif r > u
> display ('ariff win the contest');
> elseif r > v
> display ('ariff win the contest');
> elseif r > w
> display ('ariff win the contest');
> elseif r > x
> display ('ariff win the contest');
> elseif r > y
> display ('ariff win the contest');
> elseif r > z
> display ('ariff win the contest');
> elseif s > q
> display ( 'hafiz win the contest');
> elseif s > r
> display ( 'hafiz win the contest');
> elseif s > t
> display ( 'hafiz win the contest');
> elseif s > u
> display ( 'hafiz win the contest');
> elseif s > v
> display ( 'hafiz win the contest');
> elseif s > u
> display ( 'hafiz win the contest');
> elseif s > v
> display ( 'hafiz win the contest');
> elseif s > w
> display ( 'hafiz win the contest');
> elseif s > x
> display ( 'hafiz win the contest');
> elseif s > y
> display ( 'hafiz win the contest');
> elseif s > z
> display ( 'hafiz win the contest');
> elseif t > q
> display ( 'wan win the contest');
> elseif t > r
> display ( 'wan win the contest');
> elseif t > s
> display ( 'wan win the contest');
> elseif t > u
> display ( 'wan win the contest');
> elseif t > v
> display ( 'wan win the contest');
> elseif t > w
> display ( 'wan win the contest');
> elseif t > x
> display ( 'wan win the contest');
> elseif t > y
> display ( 'wan win the contest');
> else t < z
> display ( 'wan win the contest');
>
>
>

Subject: how to display the largest number in command?

From: Matt Fig

Date: 5 Apr, 2009 17:21:02

Message: 3 of 4

While what you are doing could be made to work, it is cumbersome. I would do something like this:



Names = {'akasyah','ariff','hafiz','wan','irfan',...
         'izzul','shahmi','faiz','azdli','yusrin'};
     
for ii = 1:length(Names)
sales(ii) = input (['Enter ',Names{ii},' sales= ']);
end

[mx,idx] = max(sales);
disp([Names{idx},' wins the contest.'])

Subject: how to display the largest number in command?

From: apple

Date: 5 Apr, 2009 17:31:01

Message: 4 of 4

"Wayne King" <wmkingty@gmail.com> wrote in message <grann9$7ta$1@fred.mathworks.com>...
> Hi,
> Why do you want to create so many scalar variables for your input statements? You're not making use of the fact that Matlab is vectorized. You should assign the inputs to elements of an array and then you can easily find the maximum value of the array and its location and determine who had the largest sales.
> hope that helps,
> wayne
>
> "apple " <Quixotic04@yahoo.com> wrote in message <gral4r$5ah$1@fred.mathworks.com>...
> > i 'm doing the program about finding the largest number between the sales. i tried doing the command. after that i tried to key-in the number, suppose to be it show the largest number but it in opposite way.. so this is my command.. can u please identified my mistake...
> >
> > q = input ('enter akasyah sales= ');
> > r = input ('enter ariff sales= ');
> > s = input ('enter hafiz sales= ');
> > t = input ('enter wan sales= ');
> > u = input ('enter irfan sales= ');
> > v = input ('enter izzul sales= ');
> > w = input ('enter shahmi sales= ');
> > x = input ('enter faiz sales= ');
> > y = input ('enter azdli sales= ');
> > z = input ('enter yusrin sales= ');
> >
> > if q > r
> > display ('akasyah win the contest');
> > elseif q > s
> > disp (' akasyah win the contest');
> > elseif q > t
> > display ('akasyah win the contest');
> > elseif q > u
> > display ('akasyah win the contest');
> > elseif q > v
> > display ('akasyah win the contest');
> > elseif q > w
> > display ('akasyah win the contest');
> > elseif q > x
> > display ('akasyah win the contest');
> > elseif q > y
> > display ('akasyah win the contest');
> > elseif q > z
> > display ('akasyah win the contest');
> > elseif r > q
> > display ('ariff win the contest');
> > elseif r > s
> > display ('ariff win the contest');
> > elseif r > t
> > display ('ariff win the contest');
> > elseif r > u
> > display ('ariff win the contest');
> > elseif r > v
> > display ('ariff win the contest');
> > elseif r > w
> > display ('ariff win the contest');
> > elseif r > x
> > display ('ariff win the contest');
> > elseif r > y
> > display ('ariff win the contest');
> > elseif r > z
> > display ('ariff win the contest');
> > elseif s > q
> > display ( 'hafiz win the contest');
> > elseif s > r
> > display ( 'hafiz win the contest');
> > elseif s > t
> > display ( 'hafiz win the contest');
> > elseif s > u
> > display ( 'hafiz win the contest');
> > elseif s > v
> > display ( 'hafiz win the contest');
> > elseif s > u
> > display ( 'hafiz win the contest');
> > elseif s > v
> > display ( 'hafiz win the contest');
> > elseif s > w
> > display ( 'hafiz win the contest');
> > elseif s > x
> > display ( 'hafiz win the contest');
> > elseif s > y
> > display ( 'hafiz win the contest');
> > elseif s > z
> > display ( 'hafiz win the contest');
> > elseif t > q
> > display ( 'wan win the contest');
> > elseif t > r
> > display ( 'wan win the contest');
> > elseif t > s
> > display ( 'wan win the contest');
> > elseif t > u
> > display ( 'wan win the contest');
> > elseif t > v
> > display ( 'wan win the contest');
> > elseif t > w
> > display ( 'wan win the contest');
> > elseif t > x
> > display ( 'wan win the contest');
> > elseif t > y
> > display ( 'wan win the contest');
> > else t < z
> > display ( 'wan win the contest');
> >
> >
> >

thanx.. but i tried to figure it out for 2 days .. but still can't do it
i don't know the command.. i already ask everyone but they don't know how to do it.. so the only thing that i can do is create the statement. i know that this program used while loop and others but still i don't know the command. if you can show me then i really appreciate ur help.. but if u can't then it's ok..

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us