How to split data into cell
Ältere Kommentare anzeigen
In the given excel I have 4 columns I want to split the data with respect to column 1 name as minutes and save the data of the other corresponding columns name with D1, D2, D3.
the condition should be that the data start from zero in column 1 and select the data upto next zero occure. save this data in one cell and again start saving data start from the next zero upto another zero occure.
7 Kommentare
Rik
am 27 Okt. 2021
A naive approach would be to do this with a loop row by row. When you have working code with a loop it will be likely be easy to speed this up (e.g. with something like find(data>0,1,'first')).
What did you try?
Adil Sardar
am 27 Okt. 2021
Bearbeitet: Rik
am 27 Okt. 2021
Rik
am 27 Okt. 2021
Write it out: what should happen when? What should be done for each row?
If the value of minute is 0, start a new cell and make that the current cell. If not, stay in the current cell.
Then add the value of your data to the current cell.
How would you write this in code? Also, please use the layout options of the editor.
Adil Sardar
am 27 Okt. 2021
Adil Sardar
am 27 Okt. 2021
Adil Sardar
am 27 Okt. 2021
Rik
am 27 Okt. 2021
I understand what you want, now I want to see if you can translate the text I wrote to code. Think of what should happen step by step. Can you understand why the code you posted didn't work?
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
