Effacer les filtres
Effacer les filtres

How to seperate a matrix into several parts and give names each of them?

1 vue (au cours des 30 derniers jours)
serhat tekebas
serhat tekebas le 13 Juin 2018
Modifié(e) : Stephen23 le 13 Juin 2018
Hi; I have a matrix which contain 270000 rows and 1column. It is a time domain data. I will do fast fourier transform but before fft I want to divide it several parts according to window length of spectrum. For example; I want to divide it as 1:20 000, 20 001:40 000, 40 001:60 000, ...That means first variable consist of the first 20 000 values of matrix and the second will be the second 20 000 of matrix and so. Then, I will apply fft to each of them. How fast can I do this? Firstly, I thought that I need to create several variable names and assign values (1:20 000) to each of them. I can I do this or what do you suggest?
  1 commentaire
Stephen23
Stephen23 le 13 Juin 2018
Modifié(e) : Stephen23 le 13 Juin 2018
"...I thought that I need to create several variable names and assign values (1:20 000) to each of them."
You could do this, but only if you want to force yourself into writing slow, complex, buggy code that is hard to debug, and want to make accessing your data more difficult. Read this to know why:
"...or what do you suggest?"
Just use indexing. Indexing is simple, neat, and very very efficient. Split your data into one cell array, or simply access different parts of a numeric matrix using indexing. Either way you can write simple, efficient code.

Connectez-vous pour commenter.

Réponses (1)

John D'Errico
John D'Errico le 13 Juin 2018
Don't do it.
There are MANY better ways to solve this. For example, convert your vector (via a simple reshape) into an array. I'll assume you want blocks of length 10000, since there would be exactly 13.5 blocks of length 20000.
Anew = reshape(A,10000,27);
Or, create a cell array. You can use mat2cell to do the conversion.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by