|
|
Fill a matrix without for-loop
This should be an easy one, but not for me :( Please help because I've got a headache from this one. Suppose t is a array, that is t=[1;2;3;4;5;6;......;100] e.g. How to fill a matrix without using for- loop in similar fashion with the following code, in order to accelerate the execution:
for i=1:100;k(i,:)=t(i,1):(t(i,1)+100);end
Thanks in advance
|
|
0
|
|
|
|
Reply
|
Marko
|
11/29/2010 10:16:20 PM |
|
One approach:
k2 = ones(length(t),length(t)+1);
k2(:,1) = t;
k2 = cumsum(k2,2);
|
|
0
|
|
|
|
Reply
|
Matt
|
11/29/2010 10:27:05 PM
|
|
Another way:
k = bsxfun(@plus,t,0:100)
Bruno
|
|
0
|
|
|
|
Reply
|
Bruno
|
11/30/2010 6:53:05 AM
|
|
Thanks Bruno, Matt
Works like a charm. From 2s to 0.2s. 10 times faster
|
|
0
|
|
|
|
Reply
|
Marko
|
11/30/2010 9:13:43 AM
|
|
|
3 Replies
488 Views
(page loaded in 0.064 seconds)
Similiar Articles: Fill a matrix without for-loop - comp.soft-sys.matlabThis should be an easy one, but not for me :( Please help because I've got a headache from this one. Suppose t is a array, that is t=[1;2;3;4;5;6;..... masked max (without a for loop) - comp.soft-sys.matlabHow to get matrix output by using parfor loop - comp.soft-sys ... masked max (without a for loop) - comp.soft-sys.matlab Fill a matrix without for-loop - comp.soft-sys ... changing the variable name in a FOR loop - comp.soft-sys.matlab ...Fill a matrix without for-loop - comp.soft-sys.matlab changing the variable name in a FOR loop - comp.soft-sys.matlab ... variable = cell(n,1); % Do stuff to fill cell ... Exponential Moving Average without For Loop - comp.soft-sys.matlab ...Hello, I am trying to find the rolling 30 day EMA for a time series without using a for loop ... For Loop - comp.soft-sys.matlab ..... sys.matlab ... Covariance Matrix ... Using nested for loops for Matrix multiplication - comp.soft-sys ...May be one can show how to do it without loops. I am sure if it is just basic matrix multiplications, then you do not need to use loops in Matlab. instead of For loop - comp.soft-sys.matlabFill a matrix without for-loop - comp.soft-sys.matlab instead of For loop - comp.soft-sys.matlab Hi, Please advise how to program following equation without For loop Σ(k ... Creating a matrix using a for loop - comp.soft-sys.matlab ...Fill a matrix without for-loop - comp.soft-sys.matlab Please help, how to use "for loop" to list out the coordinate ... Reshape a matrix without using a for loop | Doug's ... Another PARFOR reduction variable headache - comp.soft-sys.matlab ...Fill a matrix without for-loop - comp.soft-sys.matlab... but not for me :( Please help because I've got a headache ... sys.matlab How to get matrix output by using parfor ... How to get matrix output by using parfor loop - comp.soft-sys ...Fill a matrix without for-loop - comp.soft-sys.matlab... soft-sys.matlab Fill a matrix without for-loop - comp.soft-sys.matlab masked max (without a for loop) - comp.soft ... "Fill" in Matlab ??? - comp.soft-sys.matlabFill a matrix without for-loop - comp.soft-sys.matlab This should be an easy one, but not for me :( Please help because I've got a headache from this one. Fill a matrix without for-loop - comp.soft-sys.matlab | Computer GroupThis should be an easy one, but not for me :( Please help because I've got a headache from this one. Suppose t is a array, that is t=[1;2;3;4;5;6;..... Fill a matrix without for-loop - Newsreader - MATLAB CentralFile exchange, MATLAB Answers, newsgroup access, Links, and Blogs for the MATLAB & Simulink user community 7/26/2012 2:48:16 AM
|
|
|
|
|
|
|
|
|