Skip to content
Prev 131958 / 398506 Next

problem applying a conditional formula to each element of a matrix

I think you want to use 'ifelse':
+     ifelse(h <= phi, sigmasq * (1 - ( 1.5 * (h/phi)  - 0.5 * (h/phi)^3)), 0)
+ }
1        2        3
1  0.00000 32.51538 34.94138
2 32.51538  0.00000 67.27146
3 34.94138 67.27146  0.00000
1         2         3
1 3.9000000 0.9678766 0.8059627
2 0.9678766 3.9000000 0.0000000
3 0.8059627 0.0000000 3.9000000

        
On Dec 12, 2007 1:35 PM, Dale Steele <dale.w.steele at gmail.com> wrote: