creating different arrays on the fly

I have an 1500 x 200 array and want to create arrays for some columns that would have different name. The new array name should be a composition of text and array's column number. Then I want to place the data from the specific column of the original array into the new array with the same column name.
For example: Take the data in 5th column of the original 1500 x 200 array and programaticaly put it into an array called "col5". Then do it for column 10, column 12, etc.
Any help would be greatly appreciated.

 Réponse acceptée

Matt Fig
Matt Fig le 9 Mar 2011

4 votes

Just in case you didn't read the link Paulo gave, DON'T DO THIS!
You will end up way too many variables, then you will be asking questions like, "How can I find the average of my many many arrays?" or "How can I do XX with all of these arrays?" Instead use a cell array or keep them in the array they are in already. Why complicate things?

12 commentaires

Carlos Freyre
Carlos Freyre le 9 Mar 2011
Ok. Thanks for the heads up. I'll have to rethink the logic flow.
Paulo Silva
Paulo Silva le 9 Mar 2011
I deleted my answer (the one that was accepted and got -1 vote from Sean de, thanks dude, it's always good to know that my time here is just wasted), my participation on Matlab Answers as come to an end, good luck to you all, bye
+1 vote to you Matt Fig and Carlos Freyre please do accept Matt Fig answer, thanks
Jan
Jan le 9 Mar 2011
@Paulo: Bye. 68 people have accepted your answers and much more have voted answers. I did not agree with all of your answers or comments, but I esteemed and will miss your constructive help here.
I have the impression, that the voting and reputation system can frustrate the most productive users. Is MATLAB Answers + voting a burn-out machine?
Matt Fig
Matt Fig le 9 Mar 2011
@Paulo, I do not think that you should take things so personally. Nobody will be able to write answers that everyone agrees with, but so what? If we all learn from each other and don't take differences of opinion to heart, perhaps we can help many people learn with us.
Your contributions here will be missed if you disappear.
Matt Tearle
Matt Tearle le 9 Mar 2011
Whoa. I think I missed something...
Matt Fig
Matt Fig le 9 Mar 2011
I think what you missed can be inferred from Paulo's comment above and several of his other recent comments on Answers...
Paulo Silva
Paulo Silva le 10 Mar 2011
@Jan, I don't care about reputation/points, I removed some of my answers that were accepted and others that got votes! also gave votes against my own answers without any problem, the thing I care is that the answers accepted are the best ones and the time spent creating them be appreciated, it's rude to say -1 vote just because someone doesn't like our answer, even if that answer is exactly what the OP wanted + extra information.
@Matt Fig, the problem I see with Matlab Answers is that the OPs can chose any answer good or bad without waiting for feedback from other Matlab users, they come here to make the question and come back later to get the answers, there's no quality test besides waiting for the best answer to get the most votes, nobody waits unless there's no answer or the provided ones aren't 100% satisfactory.
@Matt Tearle, please keep up teaching others how to love matlab :)
Matt Fig
Matt Fig le 10 Mar 2011
@Paulo, what you say is true, which is why I simply do not equate an answer being chosen as best with it being the best. Perhaps you are really making a recommendation to have a "OP best answer" and another, "Community voted best answer." Even this will not be perfect. Bottom line, like the FEX, MATLAB Answers isn't perfect so don't take it personally. If you are here to help, then the rest is just fluff. That's my $.02.
Paulo Silva
Paulo Silva le 10 Mar 2011
I will try to ignore some things in the future, thanks for the wise words Matt :) I decided to keep my regular participation for now.
Matt Tearle
Matt Tearle le 10 Mar 2011
OK, I take it there was something of a flame war in the comments of Paulo's answer?
I am sorry to hear that. My main interest here is that I want this forum to be useful and successful. Paulo, the best way for that to happen is for the top people to keep doing what they've been doing so far. IOW, I'll add my name to those asking you to keep contributing, and ignore the crud. (We all have to have a sense of humor about some things.) With that said, I do want ideas on how to reduce the crud. A key aspect of MATLAB Answers is that other users should be able to find information/help by searching for questions and finding the most relevant information in the accepted and top-ranked answers. If you have ideas on how to make that happen, let's hear them. Maybe in Walter's Wish-List question. Or even start a new question, with your own suggestion as the first answer.
Paulo Silva
Paulo Silva le 10 Mar 2011
@Matt Tearle, it was not a flame war, just someone commented "-1 vote" on my answer, don't really know if that person was able or not to vote down my answer but it was kind of rude after the trouble I had to come up with code to do what was asked for and to provide a link for the proper way to do it, Matt Fig posted his answer after mine has you can see "Just in case you didn't read the link Paulo gave, DON'T DO THIS!...", my answer was the one accepted but I decided to remove it.
I won't make more suggestions, had enough problems, the only thing that should change is the way people think, if you don't agree with something just say why instead of voting down.
Jan
Jan le 10 Mar 2011
@Paulo: "The only thing that should change is the way people think"?! I'm sure that MATLAB Answers users do not want their way of thinking to be changed.
In fact, "-1 vote" is not a flame war. It is not very helpful, but simply the expression of a opinion deviating from yours. "-1E6 votes" would be another story.
@Matt: "The rest is just fluff". I asked Leo to translate this: "Der Rest ist Flockenbrennstoff". Ok. I have nothing to add.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Scripts 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!

Translated by