HELP eval - Undefined function 'eval' for input arguments of type 'cell'. - find structure (from workspace) with part of name and accessing it
古いコメントを表示
Hello, I am currently writing a code to analyse blood pressure. The blood pressure has been extracted using another language, the code renamed my channels a bit weirdly. I just need to modify my matlab code to make it flexible to all those weird names .. and I am a bit stuck.
My matlab code is looped on my participants.
For each participant, I load a .mat file (easy).
As I said the channel are weirdly renamed :
name of channel1: XYPlot *1_01_1*__Ch1
name of channel2: XYPlot *1_01_1*__Ch2
name of channel3: XYPlot *1_01_1*__Ch3
The bold part is always different between subjects.
**MY GOAL
To define:
time_Spike= channel2.xvalues;
SBP_peaks_values = channel2.yvalues;
**MY SCRIPT
namesWorkspace = who;
outStr = regexpi(namesWorkspace, 'Ch2');
ind = ~cellfun('isempty',outStr);
var = namesWorkspace(ind);
str={var};
out=str{1};
channel2=eval(out);
time_Spike= channel2.xvalues;
SBP_peaks_values = channel2.yvalues;
**OUTCOME
But I have a problem with eval
"Undefined function 'eval' for input arguments of type 'cell'."
I am sure there is another easier way to do what I want to do,
Your help and feedback would be very appreciated :)
thanks
Sophie
1 件のコメント
Image Analyst
2017 年 7 月 22 日
編集済み: Image Analyst
2017 年 7 月 22 日
Sophie, you forgot to attach the .mat file so I can't do anything (yet).
"out" appears to be the contents of a cell. We don't know what data type it is - it could be anything. But there is no reason to send in into eval(). Why did you do that???
採用された回答
その他の回答 (1 件)
Steven Lord
2017 年 7 月 22 日
1 投票
DON'T use eval. load your data into a struct array and use fieldnames and dynamic field names to access the data in the struct array.
カテゴリ
ヘルプ センター および File Exchange で Linear Predictive Coding についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!