Combine two different matrices to create one new matrix of all matrix combinations
이전 댓글 표시
Hi, I have the following matrices
WT_energy_supply(:,:,M) and PV_power_output(:,:,K)
which are 365 x 24 matrices and M = 3 and K = 10. Therefore there are 30 possible combinations of WY_energy_supply and PV_power_output. I am looking to create a set of matrices (in the form (:,:,Z)) that add corresponding elements in each matrix to form this new set (again 365x24 with 30 different matrices) Does anyone have any idea where to start coding this?
Thank you
채택된 답변
추가 답변 (2개)
Andrei Bobrov
2012년 5월 11일
eg:
M = 3;
K = 10;
WT_energy_supply = randi(10,10,4,M);
PV_power_output = randi([10 50],10,4,K);
%solution
ij = fullfact([M K]);
out = WT_energy_supply(:,:,ij(:,1)) + PV_power_output(:,:,ij(:,2)) ;
댓글 수: 5
Sean de Wolski
2012년 5월 11일
+1 for fullfact().
It's like a simple way to do the [xx yy zz ww] = meshgrid(blah)
[xx(:) yy(:)...
Learn something new everyday!
Awesome-o!
Andrew Alkiviades
2012년 5월 11일
Sean de Wolski
2012년 5월 11일
really, you shoudl decide based on:
-importance of speed.
-importance of being able to understand what's going on.
-whichever side of a coin flips up (or rand > 0.5)
Andrew Alkiviades
2012년 5월 11일
Sean de Wolski
2012년 5월 11일
That's what bsxfun does for you!
think about it, how can you add two things that are different sizes?
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!