how to extract specific columns using loops?
1 回表示 (過去 30 日間)
古いコメントを表示
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/162006/image.png)
i have data matrix of 453 rows and 55 columns. i want to extract columns of year '10-11' from excel sheet and want to write matlab file using xlswrite function..i have done this in vba programming but i don't know how to do it in matlab.AS i m working in health data..so i want to apply this code in all 19 districts and extract columns of year'10-11', '11-12', '12-13', '13-14', '14-15'.
this is my vba code:
Sub Button1_Click() Dim sh1 As Worksheet, sh2 As Worksheet Dim col As Long, rng As Range, c As Range, cRng As Range, cRws As Long, col2 As Long
Set sh1 = Sheets("Sheet1")
Set sh2 = Sheets("Sheet2")
With sh1
col = .Cells(1, .Columns.Count).End(xlToLeft).Column
Set rng = .Range(.Cells(1, 1), .Cells(1, col))
For Each c In rng.Cells
If c Like "*13-14*" Then
cRws = .Cells(.Rows.Count, c.Column).End(xlUp).Row
Set cRng = .Range(.Cells(1, c.Column), .Cells(cRws, c.Column))
cRng.Copy sh2.Cells(1, sh2.Columns.Count).End(xlToLeft).Offset(, 1)
End If
Next c
End With
sh2.Columns("A:A").EntireColumn.Delete Shift:=xlToLeft
sh2.Cells.EntireColumn.AutoFit
End Sub
i want to apply the same logic in matlab..i have tried but failed...please help me
0 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Import from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!