Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Copy with Matlab

DindogDindog Posts: 2Member
Hi!
I have this problem: I have a big data list in .txt file, with three columns and various lines; a variable number of lines constitutes a series.
At the end of each series, there is a blank line. Then another series starts.

i.e.
20 23 103
98 23 92
22 11 118

15 15 22
11 33 33
55 55 55
98 22 22

43 44 23
33 33 44

...and so on.
I would like to copy each series near the previous series.
The copy of each series should end when it reaches the blank line.

i.e.
20 23 103 15 15 22 43 44 23
98 23 92 11 33 33 33 33 44
22 11 118 55 55 55
98 22 22

I have a Macro doing this in Excel...

Sub mergeline()
Dim OutSh As Worksheet, DataSh As Worksheet
Dim I As Long, IBlkC As Long, BlkLen As Long
'
Set OutSh = ThisWorkbook.Sheets("Merge") '<< Il foglio dove si costruisce l' output
Set DataSh = ThisWorkbook.Sheets("Foglio1") '<< Il foglio con i dati di partenza
datacell = "A2" '<< La cella da cui partono i dati
'
OutSh.Cells.ClearContents
For I = 1 To DataSh.Cells(Rows.Count, Range(datacell).Column).End(xlUp).Row
If DataSh.Range(datacell).Offset(I - 1, 0) = "" Then
IBlkC = 0
Else
DataSh.Range(datacell).Offset(I - 1, 0).Resize(1, Application. _
WorksheetFunction.CountA(DataSh.Range(datacell).Offset(I - 1, 0).EntireRow)).Copy _
Destination:=OutSh.Range(datacell).Offset(IBlkC, Application.WorksheetFunction. _
CountA(OutSh.Range(datacell).Offset(IBlkC, 0).Resize(1, Columns.Count - 5)))
IBlkC = IBlkC + 1
End If
Next I
End Sub

...but I would like to do it in Matlab.
Any idea?
Thank you,

Ale
Sign In or Register to comment.