Error in gui_mainfcn
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Diana Gaier
le 19 Août 2024
Modifié(e) : Walter Roberson
le 19 Août 2024
function varargout = Ausgabe(varargin)
% AUSGABE MATLAB code for Ausgabe.fig
% AUSGABE, by itself, creates a new AUSGABE or raises the existing
% singleton*.
%
% H = AUSGABE returns the handle to a new AUSGABE or the handle to
% the existing singleton*.
%
% AUSGABE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in AUSGABE.M with the given input arguments.
%
% AUSGABE('Property','Value',...) creates a new AUSGABE or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Ausgabe_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Ausgabe_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help Ausgabe
% Last Modified by GUIDE v2.5 18-Jul-2019 11:15:33
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Ausgabe_OpeningFcn, ...
'gui_OutputFcn', @Ausgabe_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before Ausgabe is made visible.
function Ausgabe_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to Ausgabe (see VARARGIN)
% Choose default command line output for Ausgabe
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Ausgabe wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Ausgabe_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in Mark_pos.
function Mark_pos_Callback(hObject, eventdata, handles)
% hObject handle to Mark_pos (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global position pathname
uiwait(msgbox('please choose the Markerposition-Datei!','Achtung','modal'));
% [filename, pathname] = uigetfile( '*.mat');
if isempty(pathname)==1
[filename, pathname] = uigetfile('*.mat');
else
filename = uigetfile([pathname,'*.mat']);
end
load(fullfile(pathname,filename));
p=position;
vid_lad_Callback(hObject, eventdata, handles);
% --- Executes on button press in vid_lad.
function vid_lad_Callback(hObject, eventdata, handles)
% hObject handle to vid_lad (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global position sgf sgf2 h_w tetha_w alpha_w L knie_w knie_w2 d3_l sprung_w pedal_w kurbel_w fx fz F F_res beta_w beta_w2 fres kurbel_w0_index gew gew2 ho x0 y0 x1 y1 x2 y2
%% Winkelmessung
h=position.h;
knie=position.knie;
sprung=position.sprung;
fuss=position.fuss;
fx=position.kraftx(:,1);
fz=position.kraftz(:,1);
axes(handles.axes1);
%% Kniewinkelberechnungen
for i=1:length(h)
P0 = knie(i,:); %definieren Knie als Ursprungspunkt
P1 = h(i,:); %definieren H?ft als P1
P2 = sprung(i,:); %definieren Sprunggelenk als P1
n1 = (P2 - P0) / norm(P2 - P0); % Normalized vectors = Betr?g des Vektors
n2 = (P1 - P0) / norm(P1 - P0); % Normalized vectors = Betr?g des Vektors
knie_w(i) = acosd(dot(n1, n2)); % Kniewenkel
end
%%
%input Gewicht und L?nge des Unterschenkels
if isempty(gew)==1
gew={'95'};
gew2={'5'};
L={'0.4'};
else
gew={num2str(gew)};
gew2={num2str(gew2)};
L={num2str(L)};
end
gew=inputdlg({'please enter body weight in kg'},'body weight',1,gew);
gew=str2num(gew{1});
gew2=inputdlg({'please enter weight plate in kg'},'weight',1,gew2);
gew2=str2num(gew2{1});
L=inputdlg({'please enter length of lower leg in m'},'length',1,L);
L=str2num(L{1});
%% Variablen berechnen
%Patellarsehne-winkel berechnen
knie_w2 = knie_w';
beta_w = -0.000012941919 .* (knie_w2 .^3) + 0.004613095238 .* (knie_w2 .^2) - 0.204942279942 .* knie_w2 - 14.142857142856;
beta_w2 = abs(beta_w);
%Winkel zwischen Tibia und y-Achse
alpha_w2 = knie_w2 - 90;
alpha_w = abs(alpha_w2);
%Winkel zwischen Femur und Patellarsehne-winkel
tetha_w = knie_w2 - beta_w;
%Hebel?rme
d1 = L * sind(alpha_w) * 0.43;
d2 = L * sind(alpha_w);
d3 = L / 5 * sind(beta_w2);
d3_l = (0.0000000002434 .* (knie_w2 .^6) - 0.0000001568469 .* (knie_w2 .^5) + 0.0000394291959 .* (knie_w2 .^4) - 0.0049457648343 .* (knie_w2 .^3) + 0.3289434274828 .* (knie_w2 .^2) - 11.0152767344929.* knie_w2 + 170.0411753969300) / 1000;
%Gewichte
gew_fuss = 5.3 / 100 * gew;
gew_last = gew2 + 6.853; %plus gewicht der Halterung 6.853 kg
%% Kr?fte Berechnen
%Bandkraft
F1 = (fx * (L - 0.05) + gew_fuss * 9.81 * d1 + gew_last * 9.81 * d2);
F = F1 ./ d3_l;
%Femoropatellarkraft
F_res = sqrt( 2 .* (F .^2) + 2 .* (F .^2) .* cosd (tetha_w));
% %% Berechnung der Mittelwerte
%
% %suchen die min. Winkel-Werte
% [AP, locs] = findpeaks(sgolayfilt(knie_w2,3,51),'MinPeakDistance',120);
% %AP = -AP;
% l_AP = numel (AP); %Number of AP
%
% %die Messwerte der Kraft in jeden Vorgang verteilen
% for i=1:l_AP;
% if (i<l_AP)
% K{i} = F_res(locs(i):locs(i+1));
% else
% K{i} = F_res(locs(i):end);
% end
% end
% RR=padcat(K{1,:}); %die L?nge der Kraft-Werte ausgleichen
% KL=nanmean(RR'); %Mittelwert berechnen
% sgf = sgolayfilt(KL,3,51); %Filter
%
% %die Messwerte der Winkel in jeden Vorgang verteilen
% for i=1:l_AP;
% if (i<l_AP)
% WW{i} = knie_w2(locs(i):locs(i+1));
% else
% WW{i} = knie_w2(locs(i):end);
% end
% end
%
% LL=padcat(WW{1,:}); %die L?nge der Winkel-Werte ausgleichen
% WL=nanmean(LL'); %Mittelwert berechnen
% sgf2 = sgolayfilt(WL,4,51); %Filter
%%
set(handles.checkbox1,'val',1);
set(handles.checkbox6,'val',1);
% checkbox1_Callback(hObject, eventdata, handles);
% imshow(mov(1).cdata);
% --- Executes on button press in checkbox1.
function checkbox1_Callback(hObject, eventdata, handles)
% hObject handle to checkbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global knie_w2
cb1=get(handles.checkbox1,'val');
cla;
close (figure(1));
if cb1==0
legend('off');
else
set(handles.checkbox2,'val',0);
set(handles.checkbox3,'val',0);
set(handles.checkbox4,'val',0);
set(handles.checkbox5,'val',0);
set(handles.checkbox6,'val',0);
axes(handles.axes1);
%% knie
hold on;
plot (sgolayfilt(knie_w2,3,51),'r')
ylim([(min(knie_w2)-5) (max(knie_w2)+5)])
%%
xlabel('frame');
ylabel('angle of knee extension in degree');
legend('Winkel der Streckung')
end
% Untitled2;
% --- Executes on button press in checkbox2.
function checkbox2_Callback(hObject, eventdata, handles)
global F_res knie_w2 P2 sgf sgf2
cb1=get(handles.checkbox1,'val');
cb2=get(handles.checkbox2,'val');
cb3=get(handles.checkbox3,'val');
cb4=get(handles.checkbox4,'val');
cb5=get(handles.checkbox5,'val');
cb6=get(handles.checkbox6,'val');
if cb1==1 || cb5==1
cla;
close (figure(1)) ;
end
if cb2==0
delete(P2);
legend('off');
else
set(handles.checkbox1,'val',0);
set(handles.checkbox3,'val',0);
set(handles.checkbox4,'val',0);
set(handles.checkbox5,'val',0);
set(handles.checkbox6,'val',0);
axes(handles.axes1);
%% Bandkraft
hold off;
P2 = plot (knie_w2,sgolayfilt(F_res,3,51),sgf2,sgf);
%%
xlabel('angle of knie extension in degree');
ylabel('force in knie joint [N]');
legend('Kniekraft','Summation')
% x_fir_h=plot(h4,'b');
end
% for i=2:length(kurbel_w0_index)-1
%
% plot(kurbel_w0_index(i)-33,fres.h1(kurbel_w0_index(i)-2),'*');
% endhandles
% Hint: get(hObject,'Value') returns toggle state of checkbox2
legend_f(handles);
% --- Executes on button press in checkbox3.
function checkbox3_Callback(hObject, eventdata, handles)
% hObject handle to checkbox3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global F_res knie_w2 P3 sgf sgf2
cb1=get(handles.checkbox1,'val');
cb2=get(handles.checkbox2,'val');
cb3=get(handles.checkbox3,'val');
cb4=get(handles.checkbox4,'val');
cb5=get(handles.checkbox5,'val');
cb6=get(handles.checkbox6,'val');
if cb1==1 || cb5==1
cla;
close (figure(1)) ;
end
if cb3==0
delete(P3);
legend('off');
else
set(handles.checkbox1,'val',0);
set(handles.checkbox2,'val',0);
set(handles.checkbox4,'val',0);
set(handles.checkbox5,'val',0);
set(handles.checkbox6,'val',0);
%% Kniekraft
hold off;
P3 = plot (sgf2,sgf);
ylim([(min(sgf)-200) (max(sgf)+200)])
index = find(sgf==max(sgf));
txt = ['max = ', num2str(max(sgf)),' N',' ; ' num2str(sgf2(index)),' Grad'];
text(sgf2(index)-15,max(sgf)+10,txt)
%%
xlabel('angle of knie extension in degree');
ylabel('force in knie joint [N]');
legend('Kniekraft')
end
legend_f(handles);
% Hint: get(hObject,'Value') returns toggle state of checkbox3
% --- Executes on button press in checkbox4.
function checkbox4_Callback(hObject, eventdata, handles)
% hObject handle to checkbox4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global knie_w2 d3_l P4 sgf sgf2 L t
cb1=get(handles.checkbox1,'val');
cb2=get(handles.checkbox2,'val');
cb3=get(handles.checkbox3,'val');
cb4=get(handles.checkbox4,'val');
cb5=get(handles.checkbox5,'val');
cb6=get(handles.checkbox6,'val');
if cb1==1 || cb5==1
cla;
close (figure(1)) ;
end
if cb4==0
delete(P4);
legend('off');
else
set(handles.checkbox1,'val',0);
set(handles.checkbox2,'val',0);
set(handles.checkbox3,'val',0);
set(handles.checkbox5,'val',0);
set(handles.checkbox6,'val',0);
%% Berechnung der Winkel?nderung
%[min_sgf2,min_locs] = findpeaks((-1 * sgf2),'MinPeakDistance',100);
%min_sgf2 = -1 * min_sgf2;
%findpeaks((-1 * sgf2),'MinPeakDistance',100);
%
%for i = 1:length(sgf2)
% d_sgf2(i) = sgf2(i) - min_sgf2;
%end
%% Berechnung der Zeit
for i = 1:length(sgf)
t(i) = i*17/801;
end
% %% Berechnung der Leistung
% for i = min_locs:length(sgf)
% if d_sgf2(i) > 0
% P(i) = ((sgf(i) - sgf(min_locs)) * 2 * pi * L * d_sgf2 (i) / 360) / (t(i)-t(min_locs));
% else
% P(i) = NaN;
% end
% end
%% Streckungwinkel gegen Zeit
hold off;
P4 = plot (t,sgf2,'r');
ylim([(min(sgf2)-5) (max(sgf2)+5)])
xlabel('time [s]');
ylabel('angle of knie extension in degree');
legend('Winkel der Streckung')
end
legend_f(handles);
% Hint: get(hObject,'Value') returns toggle state of checkbox4
% --- Executes on button press in checkbox5.
function checkbox5_Callback(hObject, eventdata, handles)
% hObject handle to checkbox5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global fx fz f_x f_r kurbel_w0_index kurbel_w
cb1=get(handles.checkbox1,'val');
cb5=get(handles.checkbox5,'val');
cla;
if cb1==1
close (figure(1)) ;
end
if cb5==0
cla;
legend('off');
else
set(handles.checkbox1,'val',0);
set(handles.checkbox2,'val',0);
set(handles.checkbox3,'val',0);
set(handles.checkbox4,'val',0);
% f_x=plot(fx, 'm');
% hold on
% f_z=plot(fz, 'cyan');
% f_r=plot(fr, 'b');
% hold on
% f_r=plot(fres.h1,'r')
f_x=1:length(fx);
B = fir1(60,0.4);
% plot(h4,'r')
% x_fir = filtfilt (B, 1, fr);
% hold on;
f_r=plot(f_x,fx,'b',f_x,fz,'r');
xlabel('Frame');
ylabel('force in sensor [N]');
legend('x-component','z-component');
%
% cla;
% [a,b]= size(kurbel_w0_index);
% h2=zeros(length(kurbel_w0_index),359);
% h25=zeros(length(kurbel_w0_index),359);
% h26=zeros(length(kurbel_w0_index),359);
% for i=1:b-1
% j=kurbel_w0_index(i);
% % hold on
% % plot(kurbel_w(j:kurbel_w0_index(i+1)-1),fres.h1(j:kurbel_w0_index(i+1)-1))
%
% h3=fr(j:kurbel_w0_index(i+1)-1);
% h5=fx(j:kurbel_w0_index(i+1)-1);
% h6=fz(j:kurbel_w0_index(i+1)-1);
% fh(i).c=h3;
% fh5(i).c=h5;
% fh6(i).c=h6;
% h1=kurbel_w(j:kurbel_w0_index(i+1)-1);
% fh3(i).c=h1;
% % length(h1)
%
% for k=1:length(h3)
% kk=round(kurbel_w(j+k-1))-1;
% if kk<=0
% kk=1;
% end
% h2(i,kk)=(h3(k)+h2(kk));
% h25(i,kk)=(h5(k)+h25(kk));
% h26(i,kk)=(h6(k)+h26(kk));
%
% end
%
% end
%
% j=1;
% for i=1:length(h2)
% if i<21
% s1=h2(:,length(h2)-20+i:length(h2));
% s5=h25(:,length(h25)-20+i:length(h25));
% s6=h26(:,length(h26)-20+i:length(h26));
% s2=h2(:,1:i);
% s25=h25(:,1:i);
% s26=h26(:,1:i);
%
% s=[s1,s2];
% s55=[s5,s25];
% s66=[s6,s26];
% else
% s=h2(:,i-20:i);
% s55=h25(:,i-20:i);
% s66=h26(:,i-20:i);
% end
% s=s(s~=0);
% h4(i)=sum(s)/length(s);
% s55=s55(s55~=0);
% h45(i)=sum(s55)/length(s55);
% s66=s66(s66~=0);
% h46(i)=sum(s66)/length(s66);
%
% end
%
% h4(isnan(h4))=[];
% plot(h4)
% hold on
% h45(isnan(h45))=[];
% plot(h45,'r')
% h6(isnan(h46))=[];
% plot(h46,'g')
% % Hint: get(hObject,'Value') returns toggle state of checkbox5
% legend('resultierende Pedal Kraft','z-Komponente','x-Komponente');
end
% --- Executes on button press in loeschen.
function loeschen_Callback(hObject, eventdata, handles)
% hObject handle to loeschen (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
clear all;
% --- Executes on button press in checkbox6.
function checkbox6_Callback(hObject, eventdata, handles)
% hObject handle to checkbox6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global knie_w2 F_res P6 sgf sgf2 t d3_l
cb1=get(handles.checkbox1,'val');
cb2=get(handles.checkbox2,'val');
cb3=get(handles.checkbox3,'val');
cb4=get(handles.checkbox4,'val');
cb5=get(handles.checkbox5,'val');
cb6=get(handles.checkbox6,'val');
if cb1==1 || cb5==1
cla;
close (figure(1)) ;
end
if cb6==0
delete(P6);
legend('off');
else
set(handles.checkbox1,'val',0);
set(handles.checkbox2,'val',0);
set(handles.checkbox3,'val',0);
set(handles.checkbox4,'val',0);
set(handles.checkbox5,'val',0);
%% Berechnung der Zeit
for i = 1:length(sgf2)
t(i) = i*17/801;
end
%% res. Kniekraft gegen Zeit
hold off;
P6 = plot (t,sgf,'r');
ylim([(min(sgf)-200) (max(sgf)+200)])
index = find(sgf==max(sgf));
txt = ['max = ', num2str(max(sgf)),' N',' ; ' num2str(t(index)),' s'];
text(t(index)-0.20,max(sgf)+40,txt)
%%
xlabel('time [s]');
ylabel('force in knie joint [N]');
legend('Kniekraft')
end
legend_f(handles);
% Hint: get(hObject,'Value') returns toggle state of checkbox4
% Hint: get(hObject,'Value') returns toggle state of checkbox6
function legend_f(handles)
global x_fir_h x_fir_k x_fir_s
cb2=get(handles.checkbox2,'val');
cb3=get(handles.checkbox3,'val');
cb4=get(handles.checkbox4,'val');
cb6=get(handles.checkbox6,'val');
if cb6==1
i=1;
if cb2==1 && length(x_fir_h)==1
L{i}='H?ftkraft';
x_fir(i)=x_fir_h;
i=i+1;
end
if cb3==1 && length(x_fir_k)==1
L{i}='Kniekraft';
x_fir(i)=x_fir_k;
i=i+1;
end
if cb4==1 && length(x_fir_s)==1
L{i}='Sprunggelenkkraft';
x_fir(i)=x_fir_s;
i=i+1;
end
% Hint: get(hObject,'Value') returns toggle state of checkbox6
if i>1
legend(x_fir,L);
end
end
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global sgf sgf2 peaks_l peaks_v knie_w2 F_res cb1
%% Summation bestimmen
%Ausw?hlen min. bzw. max. Peaks durch -1 bzw. 1 Eingabe
% close (figure(2));
if isempty(peaks_l)==1
peaks_l={'150'};
peaks_v={'1'};
else
peaks_l={num2str(peaks_l)};
peaks_v={num2str(peaks_v)};
end
peaks_l=inputdlg({'please enter peaks distance'},'peaksdistance',1,peaks_l);
peaks_l=str2num(peaks_l{1});
peaks_v=inputdlg({'max. peaks = 1 or min. peaks = -1'},'peaksvalue',1,peaks_v);
peaks_v=str2num(peaks_v{1});
%Suchen die min. bzw max. Winkel-Werte
[AP, locs] = findpeaks(sgolayfilt(peaks_v * knie_w2,3,51),'MinPeakDistance',peaks_l);
AP = peaks_v * AP;
l_AP = numel (AP); %Number of AP
%plotting findpeaks
% cla;
figure(2);
findpeaks(sgolayfilt(peaks_v * knie_w2,3,51),'MinPeakDistance',peaks_l);
xlabel('frame');
ylabel('angle of knee extension in degree');
legend('Winkel der Streckung')
%die Messwerte der Kraft in jeden Vorgang verteilen
for i=1:l_AP;
if (i<l_AP)
K{i} = F_res(locs(i):locs(i+1));
else
K{i} = F_res(locs(i):end);
end
end
RR=padcat(K{1,:}); %die L?nge der Kraft-Werte ausgleichen
KL=nanmean(RR'); %Mittelwert berechnen
sgf = sgolayfilt(KL,3,51); %Filter
%die Messwerte der Winkel in jeden Vorgang verteilen
for i=1:l_AP;
if (i<l_AP)
WW{i} = knie_w2(locs(i):locs(i+1));
else
WW{i} = knie_w2(locs(i):end);
end
end
LL=padcat(WW{1,:}); %die L?nge der Winkel-Werte ausgleichen
WL=nanmean(LL'); %Mittelwert berechnen
sgf2 = sgolayfilt(WL,4,51); %Filter
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global sgf sgf2 t knie_w2 F_res
frame = (1:length(F_res))';
kniekraft = F_res;
kniewinkel = knie_w2;
sum_zeit = t';
sum_kniewinkel = sgf2';
sum_kniekraft = sgf';
% Get the name of the file that the user wants to save.
% Note, if you're saving an image you can use imsave() instead of uiputfile().
startingFolder = userpath; % Or "pwd" or wherever you want.
defaultFileName = fullfile(startingFolder, '.xlsx');
[baseFileName, folder] = uiputfile(defaultFileName, 'Specify a file');
if baseFileName == 0
% User clicked the Cancel button.
return;
end
fullFileName = fullfile(folder, baseFileName);
Tab1 = table(frame,kniekraft,kniewinkel);
Tab2 = table (sum_zeit,sum_kniekraft,sum_kniewinkel);
%xlswrite(fullFileName, Tab1, 'A1')
%xlswrite(fullFileName, Tab2, 'D1')
writetable(Tab1,fullFileName);
writetable(Tab2,fullFileName,'Sheet',1,'Range','D1');
Unrecognized function or variable 'nanmean'.
Error in Ausgabe>pushbutton4_Callback (line 675)
KL=nanmean(RR'); %Mittelwert berechnen
Error in gui_mainfcn (line 90)
feval(varargin{:});
Error in Ausgabe (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)Ausgabe('pushbutton4_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
0 commentaires
Réponse acceptée
Rik
le 19 Août 2024
Why did you post this wall of unformated code? Do you expect anyone to actually read it?
Lucky for you the error message tells us everything we need to know: the nanmean function call returns an error.
If you have a look at the documentation, you will see that nanmean is no longer recommended since R2020b. Replace the call with mean using the 'omitnan' flag.
KL=mean(RR','omitnan');
0 commentaires
Plus de réponses (2)
Ronit
le 19 Août 2024
Hello Diana,
‘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 anymore. Use ‘mean’ with ‘omitnan’ option to perform the same operation.
Replace all instances of ‘nanmean’ with ‘mean’ as:
mean(sampleData, 'omitnan');
Please refer to the following documentations for more details:
- ‘nanmean’ - https://www.mathworks.com/help/stats/nanmean.html
- ‘mean’ - https://www.mathworks.com/help/matlab/ref/mean.html
I hope it helps you query!
0 commentaires
Matlab Pro
le 19 Août 2024
Hi @Diana Gaier
Well, to better help you - better is not to paste the whole huge M file code, but to attach is as a file.
Anyhow - few issues:
- This is a 'M' file created with guide. Please attach both M + fig file
- In the error @ the end of your code pasted above :
- Error in Ausgabe>pushbutton4_Callback (line 675)
- this callback does not exist, in the code above (attaching the whole file, will probably consists of this callback)
Specifically - this error means that ou call a function that is not knows in the current context
You call nanmean from pushbutton4_Callback.
Where is this function defined? Looks like it is not under the PATH.
You can debug the file onl line 675 and when reaching this line (on a breakpoint) - type on the command line:
which namean
If Matlab idetifies this function - it will return the absolute path to it.
Otherwise - find where it is defined and "enable" it using one of the next ways:
- Add the path to nanmean to Matlab's PATH
- Put nanmean.m in the path where Ausgabe.m is located
- Add this function to Ausgabe.m file
Good luck!
0 commentaires
Voir également
Catégories
En savoir plus sur Matrix Indexing 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!