Extract certain values in .mat file
3 次查看(过去 30 天)
显示 更早的评论
Hi,
I have a mat file with 1250x1 data and I want to extract specific values from the 1250. For example I want to extract every 2nd or every 5th values.
As an example, the mat file contains the following values:
-0.13793 -0.114746 -0.204773 -0.224304 -0.181274 -0.192566 -0.159912 -0.174866 -0.134888 -0.148926
For every 2nd I want to read: -0.114746 -0.224304 -0.192566 -0.174866 -0.148926
For every 5th I want to read: -0.181274 -0.148926
What is the best command to do this? Thank you.
1 个评论
VBBV
2024-4-24
@Sleiman Ghorayeb To extract you need to first load the mat file into workspace and access the data variable
回答(1 个)
VBBV
2024-4-24
data= [-0.13793 -0.114746 -0.204773 -0.224304 -0.181274 -0.192566 -0.159912 -0.174866 -0.134888 -0.148926]
data(2:2:end)
data(5:5:end)
2 个评论
VBBV
2024-4-24
编辑:VBBV
2024-4-24
@Sleiman Ghorayeb yes, you can if the datatype of hb is not a structure. It its a structure, then you need to use . (dot) operator to access data from structure. can you attach data file ?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!