Function Problem that Include Workspace and Assignin
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
atahan karaman
le 12 Juin 2020
Réponse apportée : Steven Lord
le 12 Juin 2020
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.
0 commentaires
Réponse acceptée
Steven Lord
le 12 Juin 2020
Don't use assignin and global variables.
Define your functions to return output arguments and call your functions with output arguments instead.
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
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!