| MATLAB Central > MATLAB Newsreader > avoiding loops to built a z matrix of the most ... |
|
|
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Jose Date: 25 Mar, 2009 15:40:19 Message: 1 of 36 |
|
Hello us, and everyone. |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Matt Fig Date: 25 Mar, 2009 16:24:01 Message: 2 of 36 |
|
Loops have not been slow in Matlab for several releases now. OFTEN, running a loop is going to be faster than vectorizing the code. Not always, but it should definitely not be a surprise to find this is the case in any given situation. |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Roger Stafford Date: 25 Mar, 2009 16:34:01 Message: 3 of 36 |
|
"Jose " <jose.l.vega@gmail.com> wrote in message <gqdj93$qa4$1@fred.mathworks.com>... |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Bruno Luong Date: 25 Mar, 2009 16:44:02 Message: 4 of 36 |
|
"Jose " <jose.l.vega@gmail.com> wrote in message <gqdj93$qa4$1@fred.mathworks.com>... |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Jose Date: 25 Mar, 2009 17:52:01 Message: 5 of 36 |
|
"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gqdn0i$a5r$1@fred.mathworks.com>... |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Roger Stafford Date: 25 Mar, 2009 18:18:01 Message: 6 of 36 |
|
"Jose " <jose.l.vega@gmail.com> wrote in message <gqdr01$jp4$1@fred.mathworks.com>... |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Jose Date: 25 Mar, 2009 18:43:01 Message: 7 of 36 |
|
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gqdsgp$aic$1@fred.mathworks.com>... |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Bruno Luong Date: 25 Mar, 2009 18:49:01 Message: 8 of 36 |
|
"Jose " <jose.l.vega@gmail.com> wrote in message <gqdr01$jp4$1@fred.mathworks.com>... |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Bruno Luong Date: 25 Mar, 2009 18:55:03 Message: 9 of 36 |
|
"Jose " <jose.l.vega@gmail.com> wrote in message <gqdtvl$n5j$1@fred.mathworks.com>... |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Jose Date: 25 Mar, 2009 19:09:01 Message: 10 of 36 |
|
"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gqduat$hug$1@fred.mathworks.com>... |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Bruno Luong Date: 25 Mar, 2009 19:47:01 Message: 11 of 36 |
|
Yet another way: |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Jose Date: 25 Mar, 2009 20:34:01 Message: 12 of 36 |
|
"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gqe1nl$cra$1@fred.mathworks.com>... |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Bruno Luong Date: 25 Mar, 2009 21:02:02 Message: 13 of 36 |
|
And what about this? |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Matt Fig Date: 25 Mar, 2009 21:10:02 Message: 14 of 36 |
|
Just to show that the old For loop isn't as uncompetitive as it seems, try this out for giggles: |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Matt Fig Date: 25 Mar, 2009 21:27:01 Message: 15 of 36 |
|
As is often the case, I noticed an improvement that could be made after I posted. On my machine this is as fast as any other. Though definitely not as cool as Bruno's final offer. |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Matt Fig Date: 25 Mar, 2009 21:33:01 Message: 16 of 36 |
|
"Matt Fig" <spamanon@yahoo.com> wrote in message <gqe7j5$evd$1@fred.mathworks.com>... |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Jose Date: 26 Mar, 2009 00:09:01 Message: 17 of 36 |
|
"Matt Fig" <spamanon@yahoo.com> wrote in message <gqe7ud$9vm$1@fred.mathworks.com>... |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Matt Fig Date: 26 Mar, 2009 00:13:01 Message: 18 of 36 |
|
|
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Matt Fig Date: 26 Mar, 2009 00:35:02 Message: 19 of 36 |
|
Hats off to Bruno! I didn't see the shorter code he posted earlier. I don't think I can beat that one with a For loop. Nice ;) |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Jose Date: 26 Mar, 2009 00:49:01 Message: 20 of 36 |
|
"Matt Fig" <spamanon@yahoo.com> wrote in message <gqehad$k7c$1@fred.mathworks.com>... |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: us Date: 26 Mar, 2009 06:07:08 Message: 21 of 36 |
|
"Jose" |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Bruno Luong Date: 26 Mar, 2009 06:48:04 Message: 22 of 36 |
|
I must agree with us here. If there is one thing to be learn from the thread is: Do not describe only half of the problem; All aspects of the problem are their importance when optimizing. If some characteristics are hidden, no effective optimization could be achieved. |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Bruno Luong Date: 26 Mar, 2009 07:11:02 Message: 23 of 36 |
|
"Jose " <jose.l.vega@gmail.com> wrote in message <gqeh2t$aqc$1@fred.mathworks.com>... |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Jose Date: 26 Mar, 2009 10:54:00 Message: 24 of 36 |
|
"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gqf9q6$gad$1@fred.mathworks.com>... |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Jose Date: 26 Mar, 2009 15:55:04 Message: 25 of 36 |
|
"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gqf9q6$gad$1@fred.mathworks.com>... |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Bruno Luong Date: 26 Mar, 2009 18:05:02 Message: 26 of 36 |
|
"Jose " <jose.l.vega@gmail.com> wrote in message <gqg8go$o5j$1@fred.mathworks.com>... |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Jose Date: 26 Mar, 2009 18:30:20 Message: 27 of 36 |
|
"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gqgg4e$98j$1@fred.mathworks.com>... |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Matt Fig Date: 26 Mar, 2009 18:58:01 Message: 28 of 36 |
|
Why is pm being calculated when it is not being used? Why are you pre-allocating zm but not the array that is actually growing in the loop (lpms)? |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Jose Date: 26 Mar, 2009 19:10:17 Message: 29 of 36 |
|
"Matt Fig" <spamanon@yahoo.com> wrote in message <gqgj7p$dno$1@fred.mathworks.com>... |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Matt Fig Date: 26 Mar, 2009 19:21:02 Message: 30 of 36 |
|
> I need pm |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Jose Date: 26 Mar, 2009 19:50:16 Message: 31 of 36 |
|
"Matt Fig" <spamanon@yahoo.com> wrote in message <gqgkiu$il3$1@fred.mathworks.com>... |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Bruno Luong Date: 26 Mar, 2009 19:56:01 Message: 32 of 36 |
|
"Jose " <jose.l.vega@gmail.com> wrote in message <gqgm9o$jif$1@fred.mathworks.com>... |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: us Date: 26 Mar, 2009 20:08:01 Message: 33 of 36 |
|
"Bruno Luong" |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Jose Date: 26 Mar, 2009 20:32:02 Message: 34 of 36 |
|
"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gqgmkh$cj5$1@fred.mathworks.com>... |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Matt Fig Date: 27 Mar, 2009 04:19:01 Message: 35 of 36 |
|
Well, you can shave off about 10% of the run-time by using the following: |
|
Subject: avoiding loops to built a z matrix of the most efficient form From: Jose Date: 27 Mar, 2009 12:17:57 Message: 36 of 36 |
|
"Matt Fig" <spamanon@yahoo.com> wrote in message <gqhk3l$4eb$1@fred.mathworks.com>... |
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.
| Tag Activity for This Thread | ||
|---|---|---|
| Tag | Applied By | Date/Time |
| scolding | us | 26 Mar, 2009 16:10:21 |
| avoiding loops ... | Jose | 26 Mar, 2009 11:55:11 |
| avoidind loops ... | Jose | 25 Mar, 2009 15:10:32 |
| avoiding loops ... | Jose | 25 Mar, 2009 13:55:07 |
| avoiding loops ... | Jose | 25 Mar, 2009 11:40:21 |
Contact us at files@mathworks.com
