matlab中fields,如何在Matlab中將字段從數據結構保存到文件名字段?

In Matlab I have a structural array that is as follows.

在Matlab中我有一個結構數組,如下所示。

We basically have a number of datasets and each one has a name. For each dataset there is a certain number of data points, that are data that has been recorded from electrical activity in the brain, from presentation of a stimulus, over a certain number of seconds.

我們基本上有許多數據集,每個數據集都有一個名稱。對於每個數據集,存在一定數量的數據點,這些數據點是從大腦中的電活動記錄的數據,來自刺激的呈現,在一定的秒數內。

For each dataset, there was a recording of 2 seconds before the stimulus was presented and a recording of 3 seconds after the stimulus was presented. So I actually want to chop my data into 2, with data points associated to "pre" and data points associated with "post". This is quite simple to do using a for loop and I have done it and have now 2 additional fields associated with each data set.

對於每個數據集,在呈現刺激之前存在2秒的記錄,並且在呈現刺激之后存在3秒的記錄。所以我實際上想把我的數據切成2,數據點與“pre”相關聯,數據點與“post”相關聯。使用for循環這很簡單,我已經完成了它,並且現在有2個與每個數據集相關的附加字段。

FYI

FYI

ALLEEG(data_set).data ----- > this field has the original unchopped data

ALLEEG(data_set).data_pre ----- > this field has the "pre" data

ALLEEG(data_set).data_post ---- > this field has the "post" data

ALLEEG(data_set).filename ---- > this field has the filename

Now I wish to take the original filename of each dataset for e.g. if one of them was called

現在我想采用每個數據集的原始文件名,例如如果其中一個被召喚

1234L01.set

and had a field labelled data containing the full data recording of (non-chopped into "pre" and "post"), I want to save the "pre" and "post" fields that I created such that I have 2 new datasets

並且有一個標記數據的字段包含完整的數據記錄(非切入“pre”和“post”),我想保存我創建的“pre”和“post”字段,以便我有2個新的數據集

1234L01_pre.set and 1234L01_post.set

and the data field in each of these is the "pre" and the "post" respectively and any other fields associated with the dataset are maintained.

並且這些中的每一個中的數據字段分別是“前”和“后”,並且保持與數據集相關聯的任何其他字段。

I am a bit confused on how to do it because I don't understand how to take the original filename and modify it and I have lots of datasets so I don't want to do it all by hand.

我有點困惑如何做到這一點,因為我不明白如何采取原始文件名並修改它,我有很多數據集,所以我不想手動完成所有這些。

Could anybody help with this please?

請問有人幫忙嗎?

1 个解决方案

#1

1

Something like:

就像是:

[p,f,e] = fileparts ( ALLEEG(data_set).filename );

newFilename = sprintf ( '%s_pre.%s', f, e )

pre = ALLEEG(data_set).pre;

save ( newFilename, 'pre' );

newFilename = sprintf ( '%s_post.%s', f, e )

post = ALLEEG(data_set).post;

save ( newFilename, 'post' );

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值