replace elements in columns of a matrix
Afficher commentaires plus anciens
Hi, I have columns block (which is a unique function output) A and B as below. I want to replace one element from column B in A each time (as in out) so that I ll do calculations on each column in out. Is there any way to do that without running out of memory possibly avoiding loops(A and B has millions of rows).The attachment demonstrates replacement up to block 2 but this continues all the way
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 2 Déc 2015
0 votes
I am pretty sure the answer is no. The problem is that the nth row of B goes into the nth column of out. Like in your example, the 5th row of B goes into the 5th column of "out". So with millions of rows, you will have millions of rows (of course) but you will have millions of columns. That is just far, far too big - you will run out of memory. So with, say, 3 million rows, you'll have a 9*10^12 element array at 8 bytes per element - that's 72,000 gigabytes GB of RAM. I have 32 GB of RAM (more than most people) and just after I fire up MATLAB it tells me the biggest array I can have is 6 GB. Six is a long way from 72 thousand.
Why do you think you want this "out" all in memory at one time? Can't you just do your process one row at a time without computing "out" in advance? I suggest you figure out how to utilize "out" in a more clever way so that you don't have to have it all in memory at one time.
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!