Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Simplifying nested 'If' functions' topicStudent Support Forum > General > Archives > "Simplifying nested 'If' functions"

Next Comment >Help | Reply To Topic
Author Comment/Response
David
03/25/06 5:39pm

I have written out explicitly a number of nested If functions which you can see below. I was wondering if there was a way of simplifying this so that I could add more If statements without having to type them all out (otherwise there would be almost 200!)?

If[binlim[[1, 1]] < c <= binlim[[2, 1]], {1},
If[binlim[[2, 1]] < c <= binlim[[1, 2]], {1, 2},
If[binlim[[1, 2]] < c <= binlim[[3, 1]], {2},
If[binlim[[3, 1]] < c <= binlim[[2, 2]], {2, 3},
If[binlim[[2, 2]] < c <= binlim[[4, 1]], {3},
If[binlim[[4, 1]] < c <= binlim[[3, 2]], {3, 4},
If[binlim[[3, 2]] < c <= binlim[[5, 1]], {4},
If[binlim[[5, 1]] < c <= binlim[[4, 2]],{4,5} ]]]]]]]

URL: ,

Subject (listing for 'Simplifying nested 'If' functions')
Author Date Posted
Simplifying nested 'If' functions David 03/25/06 5:39pm
Re: Simplifying nested 'If' functions zooloo 04/01/06 05:12am
Next Comment >Help | Reply To Topic