ワークスペースに表示​されない変数をワーク​スペースに表示させた​い

27 views (last 30 days)
Tatsuya Onishi
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
Atsushi Ueno on 27 Jun 2022
>EPOとXをワークスペースに表示したいのですが,できず原因がわかりません。
もう一つの解釈:例えばtrain_bci()内にブレークポイントを定義して実行し、デバッグモードで下記右方の「関数呼び出しスタック」を”train_bci”にすれば、train_bci()の関数ワークスペースを表示することができます。
Tatsuya Onishi
Tatsuya Onishi on 30 Jun 2022
解決しました!
皆様ありがとうございます!!

Sign in to comment.

Accepted Answer

Hernia Baby
Hernia Baby on 28 Jun 2022
簡単な例をおいておきます。
x = 1:10;
y = randi([-3 3],1,10);
まずは出力が2つの関数
[a,b] = Myfcn(x,y)
a = 1×10
2 4 6 8 10 12 14 16 18 20
b = 1×10
3 8 2 7 6 2 2 4 2 7
続いて出力が3つの関数
[a,b,c] = Myfcn2(x,y)
a = 1×10
2 4 6 8 10 12 14 16 18 20
b = 1×10
3 8 2 7 6 2 2 4 2 7
c = 1×10
6 32 12 56 60 24 28 64 36 140
3つの関数で c だけ欲しい場合
[~,~,c] = Myfcn2(x,y)
c = 1×10
6 32 12 56 60 24 28 64 36 140
以下関数
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

More Answers (0)

Categories

Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange

Tags

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!