Gaussian Noise Error message
显示 更早的评论
Please could you look into this Gaussian Noise Simulation Error. Attached also is the error
采纳的回答
Image Analyst
2022-11-24
The error seems clear. You're tying to use "signal" in a function where it does not exist. I didn't look at the code but nowhere did you either pass in "signal" or create it in the function. You need to do one or the other.
7 个评论
I'll add
% ...
sigEner = norm(signals(:))^2; % energy of the signal
noiseEner = sigEner/(10^(reqSNR/10)); % energy of noise to be added
noiseVar = noiseEner/(length(signal(:))-1); % variance of noise to be added
St = sqrt(noiseVar); % std. deviation of noise to be added
noise = St*randn(size(signal)); % noise
noisySig = signal+noise; % noisy signal
% ...
There is a variable called signals which appears to suddenly change its name to signal
I tried adding s to signals to make it signals. My signals has been defined in the "Process Data" script
Replacing "signal" with "signals" in getmswtfeat fixes the signal problem but you have an index out of range error. I trust you can figure that one out, right?
%% load the data first
load('John_3PhaseFault0ohm.mat')
%% does this signal has any NaNs, if so remove
SteadyStateNoneFaultState = rmmissing(SteadyStateNoneFaultState);
Data3Phase0hmsFaultData = rmmissing(Data3Phase0hmsFaultData);
SSTime = SteadyStateNoneFaultState.Time;
SSNFS = SteadyStateNoneFaultState.SteadyStateNoneFaultState;
DPTime = Data3Phase0hmsFaultData.Time;
DPFD = Data3Phase0hmsFaultData.Data3Phase0hmsFaultData;
%% Define the filtering and inspect
n = 8; %% defines window length
w = [-ones(n,1); ones(n,1)];
SSNFS = filter(w, n, SSNFS);
DPFD = filter(w, n, DPFD);
%% Normalize signals
med_training = prctile(SSNFS,50);
iqr_training = iqr(SSNFS);
SSNFS = (SSNFS-med_training)./iqr_training;
med_fault = prctile(DPFD,50);
iqr_fault = iqr(DPFD);
DPFD = (DPFD-med_fault)./iqr_fault;
% Plot & Observe the data
subplot(2,1,1)
plot(DPTime, DPFD)
title('filtered Data3Phase0hmsFaultData')
subplot(2,1,2)
plot(SSTime, SSNFS)
title('filtered SteadyStateNoneFaultState')

%% Let's observe the FFT power spectrum for differences
feat_fault = getmswtfeat(DPFD,32,16,100000);
Index in position 2 exceeds array bounds. Index must not exceed 52.
Error in getmswtfeat (line 117)
prob = percentENER(:,st:en);%./repmat(sum(percentENER(:,st:en),2),1,longs(k)) + eps;
feat_Good = getmswtfeat(SSNFS,32,16,100000);
Actually the main problem figuring and fixing the index error? How do you do that?
@john amoo otoo I'd start here:
I don't have the Wavelet Toolbox and it's not possible to debug just by running code here in Answers. So the only way is for you to learn how to debug and debug it yourself. It's a skill you will need to learn eventually anyway. "Debugging via Answers" and waiting to see if someone who has the Wavelet Toolbox is willing to do your debugging for you is very slow and not reliable. It will be much faster to do it yourself.
What I am trying ti get at is to de-noise the signal and extract the features with getfeat
Yes, debugging will definitely allow you to do that. Did you learn how to debug yet from the tutorial I showed you? If not, why not?
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Denoising and Compression 的更多信息
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
