Function Problem that Include Workspace and Assignin

5 visualizzazioni (ultimi 30 giorni)
Hi guys,
Here is my writer code that use for calling functions. I use just 9964x1 double vector named "pd" to start all these functions.
Writer code:
clc;
clear global;
bandpassfilter(pd)
waveletdenoiser(bandpassfilter)
ssimer(pd,bandpassfilter,waveletdenoiser)
maxer_miner(pd,bandpassfilter,waveletdenoiser)
scaler(waveletdenoiser,ratio_range_pd_waveletdenoiser)
two_d_plotter(pd,bandpassfilter,waveletdenoiser,scaler)
For example my bandpassfilter functions is;
function bandpassfilter(pd)
bandpassfilter = bandpass(pd,[20 490], 1000);
assignin('base','bandpassfilter',bandpassfilter);
But if I don't use assignin('base','bandpassfilter',bandpassfilter); ,
I can't go other functions. Beacause such as the next functions is;
function waveletdenoiser(bandpassfilter)
bandpassfilter2 = bandpassfilter;
waveletdenoiser = wdenoise(bandpassfilter2, 10,'Wavelet','coif1', 'DenoisingMethod',{'FDR',0.1}, 'NoiseEstimate','LevelDependent');
and include the previous output from previous function "bandpassfilter".
I don't want to use assignin code to don't show all these just show scaler.
Thank you.

Risposta accettata

Steven Lord
Steven Lord il 12 Giu 2020
Don't use assignin and global variables.
Also don't try to use the same name for your function and your variables.
theFilter = bandpassfilter(pd);
theDenoiser = waveletdenoiser(theFilter)
ssimer(pd,theFilter,theDenoiser)
maxer_miner(pd,theFilter,theDenoiser)
theScaler = scaler(theDenoiser,ratio_range_pd_waveletdenoiser)
two_d_plotter(pd,theFilter,theDenoiser,theScaler)
I don't know which of your function computes the ratio_range_pd_waveletdenoiser variable, but whichever one does should return it. Here's a general outline of how your bandpassfilter function should look:
function F = bandpassfilter(pd)
% Compute F using pd here
F = sum(pd); % replace with your actual commands
% When the code above calls bandpassfilter, whatever you define F to be in here
% will be stored in the theFilter variable when bandpassfilter finishes executing
end

Più risposte (0)

Prodotti


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by