ワークスペースに表示されない変数をワークスペースに表示させたい
42 views (last 30 days)
Show older comments
Tatsuya Onishi
on 27 Jun 2022
Commented: Tatsuya Onishi
on 30 Jun 2022
分類器のアプリを用いるために変数をワークスペースに保存しようとしています。
load data_set_IVb_al_train
% バンドパスフィルタの設定 (α波とβ波)
flt = @(f)(f>7&f<30).*(1-cos((f-(7+30)/2)/(7-30)*pi*4));
% 関数呼び出し
[S,T,w,b] = train_bci(single(cnt), nfo.fs, sparse(1,mrk.pos,(mrk.y+3)/2),[0.5 3.5],flt,3,200);
function [S,T,w,b] = train_bci(EEG,Fs,mrk,wnd,f,nof,n)
[t,c] = size(EEG);
idx = reshape(1:t*c-mod(t*c,n),n,[]);
FLT = real(ifft(fft(EEG).*repmat(f(Fs*(0:t-1)/t)',1,c)));
T = FLT(idx)/EEG(idx);
% -----エポッキングとCSPの計算 -----
% 0.5~3.5sのウィンドウの設定
wnd = round(Fs*wnd(1)):round(Fs*wnd(2));
% エポッキング
EPO1 = FLT(repmat(find(mrk==1),length(wnd),1) + repmat(wnd',1,nnz(mrk==1)),:);
EPO2 = FLT(repmat(find(mrk==2),length(wnd),1) + repmat(wnd',1,nnz(mrk==2)),:);
% cspフィルタ
[V,D] = eig(cov(EPO2),cov(EPO1)+cov(EPO2));
S = V(:,[1:nof end-nof+1:end]);
% -----特徴抽出-----
X1 = squeeze(log(var(reshape(EPO1*S, length(wnd),[],2*nof))));
X2 = squeeze(log(var(reshape(EPO2*S, length(wnd),[],2*nof))));
% ------LDA------
w = ((mean(X2)-mean(X1))/(cov(X1)+cov(X2)))';
b = (mean(X1)+mean(X2))*w/2;
end
このプログラムにおいてEPOとXをワークスペースに表示したいのですが,できず原因がわかりません。
ご教授いただけると幸いです。
3 Comments
Atsushi Ueno
on 27 Jun 2022
>EPOとXをワークスペースに表示したいのですが,できず原因がわかりません。
もう一つの解釈:例えばtrain_bci()内にブレークポイントを定義して実行し、デバッグモードで下記右方の「関数呼び出しスタック」を”train_bci”にすれば、train_bci()の関数ワークスペースを表示することができます。
Accepted Answer
Hernia Baby
on 28 Jun 2022
簡単な例をおいておきます。
x = 1:10;
y = randi([-3 3],1,10);
まずは出力が2つの関数
[a,b] = Myfcn(x,y)
続いて出力が3つの関数
[a,b,c] = Myfcn2(x,y)
3つの関数で c だけ欲しい場合
[~,~,c] = Myfcn2(x,y)
以下関数
function [a,b] = Myfcn(x,y);
a = x.*2;
b = y + 5;
c = a.*b;
end
function [a,b,c] = Myfcn2(x,y);
a = x.*2;
b = y + 5;
c = a.*b;
end
0 Comments
More Answers (0)
See Also
Categories
Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!