Matrix manipulation coding with If and for loops

I have a n x 2 matrix. I want to basically look at adjacent number in the column one and if the difference in the values is greater than 1, than I want to insert a blank space in the nx2 matrix.
Can anyone please help with this?

5 Commenti

the cyclist
the cyclist il 17 Lug 2015
Modificato: the cyclist il 17 Lug 2015
There is no such thing as a "blank space" in a numeric matrix. You could insert zeros or NaNs.
A cell array can have empty elements, but you might not be able to do numerical manipulations as easily.
What will you be doing with these data at a next step?
Blank lines can be added when displaying, but that only effects how they look.
Racky
Racky il 17 Lug 2015
Modificato: Racky il 17 Lug 2015
I want to separate them out based on empty spaces and then find out the average, min and max values. I guess I can have zeroes/NaNs as well and delete them after the output file is generated in excel.
cell arrays. Separate them out and work with them one by one.
Or use accumarray with the subscript vector obtained from
ix=find(diff([0;x(:,1))>1);
to compute the statistics wanted.

Risposte (0)

Questa domanda è chiusa.

Richiesto:

il 17 Lug 2015

Chiuso:

il 20 Ago 2021

Community Treasure Hunt

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

Start Hunting!

Translated by