[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Switch statement
From: |
Juan Pablo Carbajal |
Subject: |
Re: Switch statement |
Date: |
Sun, 16 Oct 2011 11:20:35 +0200 |
On Sun, Oct 16, 2011 at 10:21 AM, Roy Menachem <address@hidden> wrote:
> Hi,
>
> For some reason when I use switch case statement by comparing strings, it
> doesn’t work.
>
> Any idea why? Is there any known problem with a string?
>
> Example:
>
> i=1;
>
> while(i<=parameters_length)
>
> switch (txt_data(i,19)) ##txt_data is array of strings
>
>
>
> case 'T1_ps'
>
> T1=num_data(i,9);
>
>
>
> case 'T2_ps'
>
> T2=num_data(i,9);
>
> case 'Min_data'
>
> min_data=num_data(i,9);
>
> otherwise
>
> printf("no value\n");
>
> endswitch
>
> i++;
>
> endwhile
>
>
>
>
>
> Thanks,
>
>
>
> Roy
>
>
>
> Roy Menachem, Marvell Israel
> Park Azorim, Kyriat Arie
> Petah Tikva, 49527, Israel
> Email: address@hidden
> Office: +972.3.9703699 - OnNet: 705.3699
> Fax: +972.3.9704905
> Mobile: +972.54.7747301
> Web site: http://www.marvell.com
>
>
> This message may contain confidential, proprietary or legally privileged
> information. The information is intended only for the use of the individual
> or entity named above. If the reader of this message is not the intended
> recipient, you are hereby notified that any dissemination, distribution or
> copying of this communication is strictly prohibited. If you have received
> this communication in error, please notify us immediately by telephone or by
> e-mail and delete the message from your computer.
>
> ________________________________
>
>
>
>
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave
>
>
The issue may not be in the switch-case statements or the comparison
with strings. The following works in 3.4.3
function f(a)
switch a
case 'aa'
disp(a)
case 'bb'
disp(a)
otherwise
disp("?")
end
end
octave> f('a')
?
octave> f('aa')
aa
octave> f('bb')
bb
--
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/