Matlab

Moderators: None (Apply to moderate this forum)
Number of threads: 1494
Number of posts: 2174

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Copy with Matlab Posted by Dindog on 20 Jun 2012 at 2:52 AM
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



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.