Problem with variable 'nanmean'.
103 ビュー (過去 30 日間)
古いコメントを表示
Hello
In my matlab script I was using 2 function scripts for despiking the data without any problem but nos I have problem with these functions and I get the error
Unrecognized function or variable 'nanmean'.
How can I solve it ?
This is my code and I also attach the func_despike_phasespace3d( ur(:,np),8, 2) data here.
the only different thing is that I am using a different version of matlab 2022b now.
clear,
close all;
clc;
%% Clear Water Mean (Q1S1)
% >>>>> 1mm VectrinoData.342.22.Vectrino Profiler.00000
% >>>>> 2mm VectrinoData.325.22.Vectrino Profiler.00000
% >>>>> 3mm VectrinoData.340.22.Vectrino Profiler.00000
%% 1mm (Sand A) here load the clear water data
load('VectrinoData.342.22.Vectrino Profiler.00000.mat')
ur=Data.Profiles_VelX;
vr=Data.Profiles_VelY;
w1r=Data.Profiles_VelZ1;
w2r=Data.Profiles_VelZ2;
k=length(Data.Profiles_TimeStamp);
% z=0.029:-0.002:0; % Starts from
% z=0:0.002:0.029; % Starts from
Q1S1_1mm=zeros(11,15);
for np=1:15
[u(:,np),ip1] = func_despike_phasespace3d( ur(:,np),8, 2);
[v(:,np), ip2] = func_despike_phasespace3d( vr(:,np),8, 2);
[w1(:,np), ip3] = func_despike_phasespace3d( w1r(:,np), 8, 2);
[w2(:,np), ip4] = func_despike_phasespace3d( w2r(:,np), 8, 2);
w(:,np)=(w1(:,np)+w2(:,np))/2;
Q1S1_1mm(1,np)=0.08-0.0450-(0.002*np);
Q1S1_1mm(2,np)=mean(u(:,np));
Q1S1_1mm(3,np)=mean(v(:,np));
Q1S1_1mm(4,np)=mean(w(:,np));
Q1S1_1mm(5,np)=std(u(:,np));
Q1S1_1mm(6,np)=std(v(:,np));
Q1S1_1mm(7,np)=std(w(:,np));
Q1S1_1mm(8,np)=0.5*( (var(u(:,np))) + var((v(:,np))) + var ((w(:,np))) ); %TKE
Q1S1_1mm(9,np)=mean( (u(:,np)-mean(u(:,np))).* (v(:,np)-mean(v(:,np))) ); %Reynolds shear stress u'v'
Q1S1_1mm(10,np)=mean( (u(:,np)-mean(u(:,np))).* (w(:,np)-mean(w(:,np))) ); %Reynolds shear stress u'w'
Q1S1_1mm(11,np)=mean( (w(:,np)-mean(w(:,np))).* (v(:,np)-mean(v(:,np))) ); % Reynolds shear stress w'v'
end
Q1S1_1mm=sortrows(transpose(Q1S1_1mm));
0 件のコメント
回答 (2 件)
Dyuman Joshi
2023 年 5 月 19 日
nanmean is a part of the "Statistics and Machine Learning Toolbox", which I believe you do not have and which is why you get the error. Additionally the use of nanmean() is not recommended (as you can see in the webpage linked).
Replace all instances of
nanmean(xyz)
with
mean(xyz, 'omitnan')
in both the functions.
2 件のコメント
Rik
2023 年 5 月 19 日
Why would you bother? Just do this replacement. It will take you a minute to do, and the error will disappear.
You can even do this (although I wouldn't recommend it):
x = nanmean([1 NaN 3])
function varargout=nanmean(varargin)
varargout = cell(1,nargout);
[varargout{:}] = mean(varargin{:},'omitnan');
end
参考
カテゴリ
Help Center および File Exchange で Stress and Strain についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!