Category: Matlab
Category Archives: Matlab
Why inpolygon is not detecting the whole artificial reef structure?
Hi,
I’m encountering a problem while trying to adjust the bathymetry in my MATLAB code. I have successfully plotted the artificial reef structure. However, I’m having difficulty modifying the bathymetry to reflect a 4-meter depth for the structure instead of the initial 5 meters. I am using the inpolygon function, but it seems to be causing some issues and not detecting the whole structure.
The code plots correctly up to line 77, but I’m experiencing problems with the polygon section. I’ve attached the MATLAB code for review.
Could you please help me identify what might be going wrong?
Thank you!Hi,
I’m encountering a problem while trying to adjust the bathymetry in my MATLAB code. I have successfully plotted the artificial reef structure. However, I’m having difficulty modifying the bathymetry to reflect a 4-meter depth for the structure instead of the initial 5 meters. I am using the inpolygon function, but it seems to be causing some issues and not detecting the whole structure.
The code plots correctly up to line 77, but I’m experiencing problems with the polygon section. I’ve attached the MATLAB code for review.
Could you please help me identify what might be going wrong?
Thank you! Hi,
I’m encountering a problem while trying to adjust the bathymetry in my MATLAB code. I have successfully plotted the artificial reef structure. However, I’m having difficulty modifying the bathymetry to reflect a 4-meter depth for the structure instead of the initial 5 meters. I am using the inpolygon function, but it seems to be causing some issues and not detecting the whole structure.
The code plots correctly up to line 77, but I’m experiencing problems with the polygon section. I’ve attached the MATLAB code for review.
Could you please help me identify what might be going wrong?
Thank you! inpolygon MATLAB Answers — New Questions
“GlobalSearch”, for some inputs ends up in “NaN” and sqpInterface and fmincon error
Hi everyone,
I have a question regarding "GlobalSearch". For some inputs, my code sometimes ends up in "NaN" and the code gives this error:
"Error using sqpInterface
Objective function is undefined at initial point. Fmincon cannot continue.
Error in fmincon (line 871)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = sqpInterface(funfcn,X,full(A),full(B),full(Aeq),full(Beq), …
Error in globaloptim.globalsearch.globalsearchnlp
Error in GlobalSearch/run (line 340)
globaloptim.globalsearch.globalsearchnlp(FUN,X0,A,B,Aeq,Beq,LB,UB,NONLCON,options,localOptions);
Error in Optimization (line 37)
[A,f] = run(gs,problem);
Caused by:
Failure in initial call to fmincon with user-supplied problem structure."
Of course, we all know that the algorithm checks the different inputs and finally goes to the smallest objective function value (error).
Is there a way to ignore the inputs that give "NaN" results and make the algorithm use other inputs to finally reach to lowest objective function value (error)?Hi everyone,
I have a question regarding "GlobalSearch". For some inputs, my code sometimes ends up in "NaN" and the code gives this error:
"Error using sqpInterface
Objective function is undefined at initial point. Fmincon cannot continue.
Error in fmincon (line 871)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = sqpInterface(funfcn,X,full(A),full(B),full(Aeq),full(Beq), …
Error in globaloptim.globalsearch.globalsearchnlp
Error in GlobalSearch/run (line 340)
globaloptim.globalsearch.globalsearchnlp(FUN,X0,A,B,Aeq,Beq,LB,UB,NONLCON,options,localOptions);
Error in Optimization (line 37)
[A,f] = run(gs,problem);
Caused by:
Failure in initial call to fmincon with user-supplied problem structure."
Of course, we all know that the algorithm checks the different inputs and finally goes to the smallest objective function value (error).
Is there a way to ignore the inputs that give "NaN" results and make the algorithm use other inputs to finally reach to lowest objective function value (error)? Hi everyone,
I have a question regarding "GlobalSearch". For some inputs, my code sometimes ends up in "NaN" and the code gives this error:
"Error using sqpInterface
Objective function is undefined at initial point. Fmincon cannot continue.
Error in fmincon (line 871)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = sqpInterface(funfcn,X,full(A),full(B),full(Aeq),full(Beq), …
Error in globaloptim.globalsearch.globalsearchnlp
Error in GlobalSearch/run (line 340)
globaloptim.globalsearch.globalsearchnlp(FUN,X0,A,B,Aeq,Beq,LB,UB,NONLCON,options,localOptions);
Error in Optimization (line 37)
[A,f] = run(gs,problem);
Caused by:
Failure in initial call to fmincon with user-supplied problem structure."
Of course, we all know that the algorithm checks the different inputs and finally goes to the smallest objective function value (error).
Is there a way to ignore the inputs that give "NaN" results and make the algorithm use other inputs to finally reach to lowest objective function value (error)? globalsearch, fmincon, sqpinterface MATLAB Answers — New Questions
Failing to create matrix from cell array in several ways
לק"י
Hi guys,
I have a cell array in 64X61X21 size.
I want to make a matrix of the values (no vectors) within specific area of the cell array – 15:21,2:61,1:21.
First I make a copy of the cell array:
cellarrayneeded=analysisdayaWT(8:15, 2:60, 1:21);
cellarrayneeded=cell2mat(cellarrayneeded);
Error message I get:
Error using cat
Dimensions of arrays being concatenated are not consistent.
Error in cell2mat (line 118)
ct{mref{:}} = cat(cdim+1,c{mref{:},:});
When I try something else:
cellarrayneeded=cell2mat(analysisdataWT{8:15, 2:60, 1:21});
I get:
Error using cell2mat
Too many input arguments.
What am I doing wrong?
Thanks!לק"י
Hi guys,
I have a cell array in 64X61X21 size.
I want to make a matrix of the values (no vectors) within specific area of the cell array – 15:21,2:61,1:21.
First I make a copy of the cell array:
cellarrayneeded=analysisdayaWT(8:15, 2:60, 1:21);
cellarrayneeded=cell2mat(cellarrayneeded);
Error message I get:
Error using cat
Dimensions of arrays being concatenated are not consistent.
Error in cell2mat (line 118)
ct{mref{:}} = cat(cdim+1,c{mref{:},:});
When I try something else:
cellarrayneeded=cell2mat(analysisdataWT{8:15, 2:60, 1:21});
I get:
Error using cell2mat
Too many input arguments.
What am I doing wrong?
Thanks! לק"י
Hi guys,
I have a cell array in 64X61X21 size.
I want to make a matrix of the values (no vectors) within specific area of the cell array – 15:21,2:61,1:21.
First I make a copy of the cell array:
cellarrayneeded=analysisdayaWT(8:15, 2:60, 1:21);
cellarrayneeded=cell2mat(cellarrayneeded);
Error message I get:
Error using cat
Dimensions of arrays being concatenated are not consistent.
Error in cell2mat (line 118)
ct{mref{:}} = cat(cdim+1,c{mref{:},:});
When I try something else:
cellarrayneeded=cell2mat(analysisdataWT{8:15, 2:60, 1:21});
I get:
Error using cell2mat
Too many input arguments.
What am I doing wrong?
Thanks! cell arrays, matrix, cell2mat MATLAB Answers — New Questions
Colors of the bar are not same for the same height in 3d bar plot after applying log scale
I’m trying to plot 3D graph with bars, in which I’m using colormap. I have found a work around to apply colormap on bar3:
b = […] % my data
for k = 1:length(b)
zdata = b(k).ZData;
b(k).CData = zdata;
b(k).FaceColor = ‘interp’;
end
colormap(‘jet’)
I’m also applying log scale in Z axis. But it was messing up my plot and I found a work around for this also.
% Z log fix
llim = .1;
h = get(gca,’Children’);
for i = 1:length(h)
ZData = get(h(i), ‘ZData’);
ZData(ZData==0) = llim;
set(h(i), ‘ZData’, ZData);
end
But I’m getting the following result after the log fix where the bars don’t have same color at the same Z value (height).
I’m trying to get results like the following plot.
Anyone know the solution?I’m trying to plot 3D graph with bars, in which I’m using colormap. I have found a work around to apply colormap on bar3:
b = […] % my data
for k = 1:length(b)
zdata = b(k).ZData;
b(k).CData = zdata;
b(k).FaceColor = ‘interp’;
end
colormap(‘jet’)
I’m also applying log scale in Z axis. But it was messing up my plot and I found a work around for this also.
% Z log fix
llim = .1;
h = get(gca,’Children’);
for i = 1:length(h)
ZData = get(h(i), ‘ZData’);
ZData(ZData==0) = llim;
set(h(i), ‘ZData’, ZData);
end
But I’m getting the following result after the log fix where the bars don’t have same color at the same Z value (height).
I’m trying to get results like the following plot.
Anyone know the solution? I’m trying to plot 3D graph with bars, in which I’m using colormap. I have found a work around to apply colormap on bar3:
b = […] % my data
for k = 1:length(b)
zdata = b(k).ZData;
b(k).CData = zdata;
b(k).FaceColor = ‘interp’;
end
colormap(‘jet’)
I’m also applying log scale in Z axis. But it was messing up my plot and I found a work around for this also.
% Z log fix
llim = .1;
h = get(gca,’Children’);
for i = 1:length(h)
ZData = get(h(i), ‘ZData’);
ZData(ZData==0) = llim;
set(h(i), ‘ZData’, ZData);
end
But I’m getting the following result after the log fix where the bars don’t have same color at the same Z value (height).
I’m trying to get results like the following plot.
Anyone know the solution? bar3, 3d plots, colormap MATLAB Answers — New Questions
How can I turn a 1*1 cell into a cell array?
For example, what is the easiest way to turn a 1*1 cell ‘a b c d e’ into a cell array {‘a’} {‘b’} {‘c’} {‘d’} {‘e’}? Please! Anyone can help me?For example, what is the easiest way to turn a 1*1 cell ‘a b c d e’ into a cell array {‘a’} {‘b’} {‘c’} {‘d’} {‘e’}? Please! Anyone can help me? For example, what is the easiest way to turn a 1*1 cell ‘a b c d e’ into a cell array {‘a’} {‘b’} {‘c’} {‘d’} {‘e’}? Please! Anyone can help me? cell, cell array, split MATLAB Answers — New Questions
Pareto Optimization of 3 Parameters (Emission, Cost and Efficiency)
Hello 🙂
I want to make an Pareto Optimization of 3 Parameters. I have got 3 Types of energy generation plants. Every Type has got his own Costs, Emission and Efficiencys. So I want to Optimize them.
I found a Minimize function (viennet function) in a Matlab Tutorial on Youtube. Is that correct? Or how could I write a function to that problem?
Thanks forward!
Greetings,
AndreaHello 🙂
I want to make an Pareto Optimization of 3 Parameters. I have got 3 Types of energy generation plants. Every Type has got his own Costs, Emission and Efficiencys. So I want to Optimize them.
I found a Minimize function (viennet function) in a Matlab Tutorial on Youtube. Is that correct? Or how could I write a function to that problem?
Thanks forward!
Greetings,
Andrea Hello 🙂
I want to make an Pareto Optimization of 3 Parameters. I have got 3 Types of energy generation plants. Every Type has got his own Costs, Emission and Efficiencys. So I want to Optimize them.
I found a Minimize function (viennet function) in a Matlab Tutorial on Youtube. Is that correct? Or how could I write a function to that problem?
Thanks forward!
Greetings,
Andrea optimization, pareto front MATLAB Answers — New Questions
How to Install and Use Gazebo Plugin in Simulink for Accessing ROS Topics with MAVROS and PX4 Autopilot?
I’m working on a project where I use Simulink to interface with ROS and Gazebo. My setup involves communicating with an Iris drone that uses the PX4 Autopilot, and I am using MAVROS for this communication. Typically, I launch ROS and Gazebo using the following commands:
HEADLESS=1 make px4_sitl gazebo
roslaunch mavros px4.launch fcu_url:="udp://:14540@127.0.0.1:14540"
However, I’m having difficulty accessing ROS topics from within the Simulink environment. I believe I need to install the Gazebo plugin for Simulink, but I’m unsure of the exact steps to do this.
Could someone guide me through the process of installing and configuring the Gazebo plugin in Simulink? Any specific instructions for ensuring that I can properly access ROS topics from Simulink would be greatly appreciated.I’m working on a project where I use Simulink to interface with ROS and Gazebo. My setup involves communicating with an Iris drone that uses the PX4 Autopilot, and I am using MAVROS for this communication. Typically, I launch ROS and Gazebo using the following commands:
HEADLESS=1 make px4_sitl gazebo
roslaunch mavros px4.launch fcu_url:="udp://:14540@127.0.0.1:14540"
However, I’m having difficulty accessing ROS topics from within the Simulink environment. I believe I need to install the Gazebo plugin for Simulink, but I’m unsure of the exact steps to do this.
Could someone guide me through the process of installing and configuring the Gazebo plugin in Simulink? Any specific instructions for ensuring that I can properly access ROS topics from Simulink would be greatly appreciated. I’m working on a project where I use Simulink to interface with ROS and Gazebo. My setup involves communicating with an Iris drone that uses the PX4 Autopilot, and I am using MAVROS for this communication. Typically, I launch ROS and Gazebo using the following commands:
HEADLESS=1 make px4_sitl gazebo
roslaunch mavros px4.launch fcu_url:="udp://:14540@127.0.0.1:14540"
However, I’m having difficulty accessing ROS topics from within the Simulink environment. I believe I need to install the Gazebo plugin for Simulink, but I’m unsure of the exact steps to do this.
Could someone guide me through the process of installing and configuring the Gazebo plugin in Simulink? Any specific instructions for ensuring that I can properly access ROS topics from Simulink would be greatly appreciated. simulink, ros, gazebo, px4, mavros MATLAB Answers — New Questions
I need help for optimization using Ga
I want to make optimization using genetic algorithm to minimize error between force and displacement (simulated and desired ) . I have 3 numbers of variables (height , depth , width) .. can anyone help me for the coding pleaseI want to make optimization using genetic algorithm to minimize error between force and displacement (simulated and desired ) . I have 3 numbers of variables (height , depth , width) .. can anyone help me for the coding please I want to make optimization using genetic algorithm to minimize error between force and displacement (simulated and desired ) . I have 3 numbers of variables (height , depth , width) .. can anyone help me for the coding please matlab, genetic algorithm MATLAB Answers — New Questions
how i can fix internal change in number of elements in yolo v4 network while training
Error using reshape
Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate size for that dimension.
Error in trainYOLOv4ObjectDetector>iGetMaxIOUPredictedWithGroundTruth (line 565)
iou(:,:,:,batchSize) = reshape(maxOverlap,h,w,c);
Error in trainYOLOv4ObjectDetector>iGenerateTargets (line 418)
iou = iGetMaxIOUPredictedWithGroundTruth(bx,by,bw,bh,groundTruth,isRotatedBox);
Error in trainYOLOv4ObjectDetector>calculateLoss (line 302)
[boxTarget, objectnessTarget, classTarget, objectMaskTarget, boxErrorScale] = iGenerateTargets(gatheredPredictions, YTrain, params.InputSize, params.AnchorBoxes, penaltyThreshold, isRotatedBox);
Error in trainYOLOv4ObjectDetector>@(varargin)calculateLoss(lossParams,isRotatedBox,varargin) (line 226)
lossFcn = @(varargin) calculateLoss(lossParams,isRotatedBox,varargin);
Error in images.dltrain.internal.SerialTrainer>modelGradients (line 140)
loss = lossFcn(networkOutputs{:},targets{:});
Error in deep.internal.dlfeval (line 17)
[varargout{1:nargout}] = fun(x{:});
Error in deep.internal.dlfevalWithNestingCheck (line 19)
[varargout{1:nargout}] = deep.internal.dlfeval(fun,varargin{:});
Error in dlfeval (line 31)
[varargout{1:nargout}] = deep.internal.dlfevalWithNestingCheck(fun,varargin{:});
Error in images.dltrain.internal.SerialTrainer/fit (line 76)
[loss,grad,state,networkOutputs,lossData] = dlfeval(@modelGradients,self.Network,self.LossFcn,…
Error in images.dltrain.internal.dltrain (line 114)
net = fit(networkTrainer);
Error in trainYOLOv4ObjectDetector (line 245)
[trainedDetector,infoTrain] = images.dltrain.internal.dltrain(mbq,detector,options,lossFcn,metrics,validationPatienceMetric,’ExperimentMonitor’,params.ExperimentMonitor);
I have single class dataset withy class name person and this is error i am facing a time of training, i have gpu compute capacity 5.2 with gpu Nvidia M400
what could be issue here , i am cofuse that is it with preprocessing or compute capacityError using reshape
Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate size for that dimension.
Error in trainYOLOv4ObjectDetector>iGetMaxIOUPredictedWithGroundTruth (line 565)
iou(:,:,:,batchSize) = reshape(maxOverlap,h,w,c);
Error in trainYOLOv4ObjectDetector>iGenerateTargets (line 418)
iou = iGetMaxIOUPredictedWithGroundTruth(bx,by,bw,bh,groundTruth,isRotatedBox);
Error in trainYOLOv4ObjectDetector>calculateLoss (line 302)
[boxTarget, objectnessTarget, classTarget, objectMaskTarget, boxErrorScale] = iGenerateTargets(gatheredPredictions, YTrain, params.InputSize, params.AnchorBoxes, penaltyThreshold, isRotatedBox);
Error in trainYOLOv4ObjectDetector>@(varargin)calculateLoss(lossParams,isRotatedBox,varargin) (line 226)
lossFcn = @(varargin) calculateLoss(lossParams,isRotatedBox,varargin);
Error in images.dltrain.internal.SerialTrainer>modelGradients (line 140)
loss = lossFcn(networkOutputs{:},targets{:});
Error in deep.internal.dlfeval (line 17)
[varargout{1:nargout}] = fun(x{:});
Error in deep.internal.dlfevalWithNestingCheck (line 19)
[varargout{1:nargout}] = deep.internal.dlfeval(fun,varargin{:});
Error in dlfeval (line 31)
[varargout{1:nargout}] = deep.internal.dlfevalWithNestingCheck(fun,varargin{:});
Error in images.dltrain.internal.SerialTrainer/fit (line 76)
[loss,grad,state,networkOutputs,lossData] = dlfeval(@modelGradients,self.Network,self.LossFcn,…
Error in images.dltrain.internal.dltrain (line 114)
net = fit(networkTrainer);
Error in trainYOLOv4ObjectDetector (line 245)
[trainedDetector,infoTrain] = images.dltrain.internal.dltrain(mbq,detector,options,lossFcn,metrics,validationPatienceMetric,’ExperimentMonitor’,params.ExperimentMonitor);
I have single class dataset withy class name person and this is error i am facing a time of training, i have gpu compute capacity 5.2 with gpu Nvidia M400
what could be issue here , i am cofuse that is it with preprocessing or compute capacity Error using reshape
Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate size for that dimension.
Error in trainYOLOv4ObjectDetector>iGetMaxIOUPredictedWithGroundTruth (line 565)
iou(:,:,:,batchSize) = reshape(maxOverlap,h,w,c);
Error in trainYOLOv4ObjectDetector>iGenerateTargets (line 418)
iou = iGetMaxIOUPredictedWithGroundTruth(bx,by,bw,bh,groundTruth,isRotatedBox);
Error in trainYOLOv4ObjectDetector>calculateLoss (line 302)
[boxTarget, objectnessTarget, classTarget, objectMaskTarget, boxErrorScale] = iGenerateTargets(gatheredPredictions, YTrain, params.InputSize, params.AnchorBoxes, penaltyThreshold, isRotatedBox);
Error in trainYOLOv4ObjectDetector>@(varargin)calculateLoss(lossParams,isRotatedBox,varargin) (line 226)
lossFcn = @(varargin) calculateLoss(lossParams,isRotatedBox,varargin);
Error in images.dltrain.internal.SerialTrainer>modelGradients (line 140)
loss = lossFcn(networkOutputs{:},targets{:});
Error in deep.internal.dlfeval (line 17)
[varargout{1:nargout}] = fun(x{:});
Error in deep.internal.dlfevalWithNestingCheck (line 19)
[varargout{1:nargout}] = deep.internal.dlfeval(fun,varargin{:});
Error in dlfeval (line 31)
[varargout{1:nargout}] = deep.internal.dlfevalWithNestingCheck(fun,varargin{:});
Error in images.dltrain.internal.SerialTrainer/fit (line 76)
[loss,grad,state,networkOutputs,lossData] = dlfeval(@modelGradients,self.Network,self.LossFcn,…
Error in images.dltrain.internal.dltrain (line 114)
net = fit(networkTrainer);
Error in trainYOLOv4ObjectDetector (line 245)
[trainedDetector,infoTrain] = images.dltrain.internal.dltrain(mbq,detector,options,lossFcn,metrics,validationPatienceMetric,’ExperimentMonitor’,params.ExperimentMonitor);
I have single class dataset withy class name person and this is error i am facing a time of training, i have gpu compute capacity 5.2 with gpu Nvidia M400
what could be issue here , i am cofuse that is it with preprocessing or compute capacity preprocessing, computer vision MATLAB Answers — New Questions
How to increase maximum number of epochs in Neural Network toolbox?
Hello, as I am traning large set of data and with large number of layer size, the default 1000 epoch are not enough. I want to increase these number of epochs but I do not see any option in the neural network fitting toolbox. I have seen somewhere that we can add that as line in MATLAB code, but I want to adjust that in the toolbox. Where can I find it?Hello, as I am traning large set of data and with large number of layer size, the default 1000 epoch are not enough. I want to increase these number of epochs but I do not see any option in the neural network fitting toolbox. I have seen somewhere that we can add that as line in MATLAB code, but I want to adjust that in the toolbox. Where can I find it? Hello, as I am traning large set of data and with large number of layer size, the default 1000 epoch are not enough. I want to increase these number of epochs but I do not see any option in the neural network fitting toolbox. I have seen somewhere that we can add that as line in MATLAB code, but I want to adjust that in the toolbox. Where can I find it? neural network, deep learning, neural networks MATLAB Answers — New Questions
Edge detection with DIC pattern.
Need some help/advice with an edge detection method. I am looking at edge of cylinderical sample that contains a DIC pattern. I have tried some various basic stuff like the edge() and hough transformation, but I either have all of the DIC pattern showing in the edge image, or the edge of the sample is incomplete and no good.
anyone have any experience with this and could point me in the right direction please?Need some help/advice with an edge detection method. I am looking at edge of cylinderical sample that contains a DIC pattern. I have tried some various basic stuff like the edge() and hough transformation, but I either have all of the DIC pattern showing in the edge image, or the edge of the sample is incomplete and no good.
anyone have any experience with this and could point me in the right direction please? Need some help/advice with an edge detection method. I am looking at edge of cylinderical sample that contains a DIC pattern. I have tried some various basic stuff like the edge() and hough transformation, but I either have all of the DIC pattern showing in the edge image, or the edge of the sample is incomplete and no good.
anyone have any experience with this and could point me in the right direction please? edge, image analysis, image processing MATLAB Answers — New Questions
QPSK Transmitter and Receiver in Simulink question
Hi everyone, I searched for questions related to this example, but didn’t find the answer.
I imported a binary data file based on the receiver module for this example. It can run before frame synchronization block, but once frame synchronization is added, an error will be reported.
The main error message is as follows:
Caused by:
Input length must be equal to or greater than output frame length.
Error in port widths or dimensions. ‘Output Port 2’ of ‘test2/Preamble Detector’ is a matrix with a maximum size of [141×1].
I guess it’s a parameter problem with the preamble detection module and frame synchronization module, but I don’t know how to make them compatible?
Looking forward to every possible helpHi everyone, I searched for questions related to this example, but didn’t find the answer.
I imported a binary data file based on the receiver module for this example. It can run before frame synchronization block, but once frame synchronization is added, an error will be reported.
The main error message is as follows:
Caused by:
Input length must be equal to or greater than output frame length.
Error in port widths or dimensions. ‘Output Port 2’ of ‘test2/Preamble Detector’ is a matrix with a maximum size of [141×1].
I guess it’s a parameter problem with the preamble detection module and frame synchronization module, but I don’t know how to make them compatible?
Looking forward to every possible help Hi everyone, I searched for questions related to this example, but didn’t find the answer.
I imported a binary data file based on the receiver module for this example. It can run before frame synchronization block, but once frame synchronization is added, an error will be reported.
The main error message is as follows:
Caused by:
Input length must be equal to or greater than output frame length.
Error in port widths or dimensions. ‘Output Port 2’ of ‘test2/Preamble Detector’ is a matrix with a maximum size of [141×1].
I guess it’s a parameter problem with the preamble detection module and frame synchronization module, but I don’t know how to make them compatible?
Looking forward to every possible help simulation, qpsk, demodulation MATLAB Answers — New Questions
Error while trying the option protected model
Hello team,
we are trying our model to get protected. But while giving the protected model option we are getting an error "Index exceeds the number of array elements. Index must not exceed 0
"Hello team,
we are trying our model to get protected. But while giving the protected model option we are getting an error "Index exceeds the number of array elements. Index must not exceed 0
" Hello team,
we are trying our model to get protected. But while giving the protected model option we are getting an error "Index exceeds the number of array elements. Index must not exceed 0
" simulation, simulink MATLAB Answers — New Questions
Interface issue of impedance calculator app by powergui for R2024a version
Hi all,
After updating to R2024a, I found an interface problem in my simulink.
When using the "Impedance calculator" app from the "powergui" in the Simulink R2024a, the app interface always has an inappropriate size and window, as shown in the figure attached, and I have no idea how to adjust it, even reinstall or default every setting.
Dose anyone know how to solve this? Thank you.Hi all,
After updating to R2024a, I found an interface problem in my simulink.
When using the "Impedance calculator" app from the "powergui" in the Simulink R2024a, the app interface always has an inappropriate size and window, as shown in the figure attached, and I have no idea how to adjust it, even reinstall or default every setting.
Dose anyone know how to solve this? Thank you. Hi all,
After updating to R2024a, I found an interface problem in my simulink.
When using the "Impedance calculator" app from the "powergui" in the Simulink R2024a, the app interface always has an inappropriate size and window, as shown in the figure attached, and I have no idea how to adjust it, even reinstall or default every setting.
Dose anyone know how to solve this? Thank you. simulink, r2024a, powergui, impedance claculator MATLAB Answers — New Questions
Autosar packages for autocode
I am working in auto generating code from a simulink model. I need it be autosar compatible. My question is: Which matlab packages related to AUTOSAR do I need other than AUTOSAR blockset?
Are any of these needed:
Simulink Check
Simulink Coverage
Simulink RequirementsI am working in auto generating code from a simulink model. I need it be autosar compatible. My question is: Which matlab packages related to AUTOSAR do I need other than AUTOSAR blockset?
Are any of these needed:
Simulink Check
Simulink Coverage
Simulink Requirements I am working in auto generating code from a simulink model. I need it be autosar compatible. My question is: Which matlab packages related to AUTOSAR do I need other than AUTOSAR blockset?
Are any of these needed:
Simulink Check
Simulink Coverage
Simulink Requirements autosar, simulink MATLAB Answers — New Questions
Unable to create mex function ‘XX_Simulinkfunction_sfun.mexw64’ required for simulation.
I am trying to call custom c code in my stateflow and got below error
Making simulation target "XX_Simulinkfunction_sfun", … Microsoft (R) Program Maintenance Utility Version 14.10.25019.0 Copyright (C) Microsoft Corporation. All rights reserved. NMAKE : fatal error U1065: invalid option ‘-‘ Stop.
Component:Make | Category:Make error
Unable to create mex function ‘XX_Simulinkfunction_sfun.mexw64’ required for simulation.
example.c
#include "example.h"
double busactive(double u1, double u2)
{
double retval;
retval = u1 + u2;
return (retval);
}
example.h
#define TRUE 1
#define FALSE 0
#define MAYBE 2
double busactive(double, double);
added #include "example.h" in simulation target Header file section and example.c is source file section.
using 2018a matlab and MEX configured to use ‘Microsoft Visual C++ 2017 (C)’ for C language compilation.
Could anyone help me solving this issue.I am trying to call custom c code in my stateflow and got below error
Making simulation target "XX_Simulinkfunction_sfun", … Microsoft (R) Program Maintenance Utility Version 14.10.25019.0 Copyright (C) Microsoft Corporation. All rights reserved. NMAKE : fatal error U1065: invalid option ‘-‘ Stop.
Component:Make | Category:Make error
Unable to create mex function ‘XX_Simulinkfunction_sfun.mexw64’ required for simulation.
example.c
#include "example.h"
double busactive(double u1, double u2)
{
double retval;
retval = u1 + u2;
return (retval);
}
example.h
#define TRUE 1
#define FALSE 0
#define MAYBE 2
double busactive(double, double);
added #include "example.h" in simulation target Header file section and example.c is source file section.
using 2018a matlab and MEX configured to use ‘Microsoft Visual C++ 2017 (C)’ for C language compilation.
Could anyone help me solving this issue. I am trying to call custom c code in my stateflow and got below error
Making simulation target "XX_Simulinkfunction_sfun", … Microsoft (R) Program Maintenance Utility Version 14.10.25019.0 Copyright (C) Microsoft Corporation. All rights reserved. NMAKE : fatal error U1065: invalid option ‘-‘ Stop.
Component:Make | Category:Make error
Unable to create mex function ‘XX_Simulinkfunction_sfun.mexw64’ required for simulation.
example.c
#include "example.h"
double busactive(double u1, double u2)
{
double retval;
retval = u1 + u2;
return (retval);
}
example.h
#define TRUE 1
#define FALSE 0
#define MAYBE 2
double busactive(double, double);
added #include "example.h" in simulation target Header file section and example.c is source file section.
using 2018a matlab and MEX configured to use ‘Microsoft Visual C++ 2017 (C)’ for C language compilation.
Could anyone help me solving this issue. nmake : fatal error u1065 MATLAB Answers — New Questions
How to use C Caller block with C code having multiple functions ?
I want to use a C language code into simulink which has multiple functions in it. Can it be done by C Caller block.I want to use a C language code into simulink which has multiple functions in it. Can it be done by C Caller block. I want to use a C language code into simulink which has multiple functions in it. Can it be done by C Caller block. simulink, code generation MATLAB Answers — New Questions
Error in gui_mainfcn
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.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. 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. gui MATLAB Answers — New Questions
Transfer Function of a RLC circuit 2 loop
how i can get a Transfer Function of a RLC circuit 2 loop if i want the output currenthow i can get a Transfer Function of a RLC circuit 2 loop if i want the output current how i can get a Transfer Function of a RLC circuit 2 loop if i want the output current transfer function of a rlc circuit 2 loop MATLAB Answers — New Questions
Numerical method to solve matric for eigen values of matrix (the input of matrix is an array)?
Data1 = readtable(‘D:VIT PHDWork 3 _ Exceptional SensingCST FilesAeiphi.xlsx’);
T1=table2array(Data1);
freq = T1(:,2); % Frequency (in THz)
txx = T1(:,3); % Amplitude of Co-Polarozation XX
P1 = T1(:,4); % Phase of Co-Polarozation XX
tyy = T1(:,5); % Amplitude of Co-Polarozation YY
P2 = T1(:,6); % Phase of Co-Polarozation YY
txy = T1(:,7); % Amplitude of Cross-Polarozation XY
P3 = T1(:,8); % Phase of Cross-Polarozation XY
tyx = T1(:,9); % Amplitude of Cross-Polarozation YX
P4 = T1(:,10); % Phase of Cross-Polarozation YX
T_XX = txx.*exp(1i.*P1); % Transmittance of co – polarozation of XX
T_YY = tyy.*exp(1i.*P2); % Transmittance of co – polarizarion of yy
T_XY = txy.*exp(1i.*P3); % Transmittance of cross polarization of xy
T_YX = tyx.*exp(1i.*P4); % Transmittance of cross polarization of yx
TT = table(T_XX,T_YY,T_XY,T_YX);
%%%% Eigen Matrix
ii = 1:1:1002;
n = length(ii);
for i = 1:n
T = [T_XX(i,1), T_XY(i,1); T_YX(i,1), T_YY(i,1)]; % Eigen Matrix for each frequency
E = eig(T); % Eigen Values
val = [E(1,1), E(2,1)]; % Reordering the Matrix
E1(i,1) = val(:,1); % Eigen Value 1
E2(i,1) = val(:,2); % Eigen value 2
ii=ii+1;
ES1(:,1) = real(E1(:,1));
ES2(:,1) = real(E2(:,1));
ephi1(:,1) = imag(E1(:,1));
ephi2(:,1) = imag(E2(:,1));
end
%% From eigen values separate real and imaginary part.
% (Real part: Transmission coffecient, Imaginary part: Phase)
a = abs(ES1);
b = abs(ES2);
c = ephi1;
d = ephi2;
T2 = table(a,b,c,d)
figure
plot(freq,a) % Plot of freq vs real eigen value 1 and 2
plot(freq,b)
ylim([0 1])
plot(freq,ephi1,freq,ephi2) % Plot of freq vs imag eigen value 1 and 2
ylim([-0.6 0.6])Data1 = readtable(‘D:VIT PHDWork 3 _ Exceptional SensingCST FilesAeiphi.xlsx’);
T1=table2array(Data1);
freq = T1(:,2); % Frequency (in THz)
txx = T1(:,3); % Amplitude of Co-Polarozation XX
P1 = T1(:,4); % Phase of Co-Polarozation XX
tyy = T1(:,5); % Amplitude of Co-Polarozation YY
P2 = T1(:,6); % Phase of Co-Polarozation YY
txy = T1(:,7); % Amplitude of Cross-Polarozation XY
P3 = T1(:,8); % Phase of Cross-Polarozation XY
tyx = T1(:,9); % Amplitude of Cross-Polarozation YX
P4 = T1(:,10); % Phase of Cross-Polarozation YX
T_XX = txx.*exp(1i.*P1); % Transmittance of co – polarozation of XX
T_YY = tyy.*exp(1i.*P2); % Transmittance of co – polarizarion of yy
T_XY = txy.*exp(1i.*P3); % Transmittance of cross polarization of xy
T_YX = tyx.*exp(1i.*P4); % Transmittance of cross polarization of yx
TT = table(T_XX,T_YY,T_XY,T_YX);
%%%% Eigen Matrix
ii = 1:1:1002;
n = length(ii);
for i = 1:n
T = [T_XX(i,1), T_XY(i,1); T_YX(i,1), T_YY(i,1)]; % Eigen Matrix for each frequency
E = eig(T); % Eigen Values
val = [E(1,1), E(2,1)]; % Reordering the Matrix
E1(i,1) = val(:,1); % Eigen Value 1
E2(i,1) = val(:,2); % Eigen value 2
ii=ii+1;
ES1(:,1) = real(E1(:,1));
ES2(:,1) = real(E2(:,1));
ephi1(:,1) = imag(E1(:,1));
ephi2(:,1) = imag(E2(:,1));
end
%% From eigen values separate real and imaginary part.
% (Real part: Transmission coffecient, Imaginary part: Phase)
a = abs(ES1);
b = abs(ES2);
c = ephi1;
d = ephi2;
T2 = table(a,b,c,d)
figure
plot(freq,a) % Plot of freq vs real eigen value 1 and 2
plot(freq,b)
ylim([0 1])
plot(freq,ephi1,freq,ephi2) % Plot of freq vs imag eigen value 1 and 2
ylim([-0.6 0.6]) Data1 = readtable(‘D:VIT PHDWork 3 _ Exceptional SensingCST FilesAeiphi.xlsx’);
T1=table2array(Data1);
freq = T1(:,2); % Frequency (in THz)
txx = T1(:,3); % Amplitude of Co-Polarozation XX
P1 = T1(:,4); % Phase of Co-Polarozation XX
tyy = T1(:,5); % Amplitude of Co-Polarozation YY
P2 = T1(:,6); % Phase of Co-Polarozation YY
txy = T1(:,7); % Amplitude of Cross-Polarozation XY
P3 = T1(:,8); % Phase of Cross-Polarozation XY
tyx = T1(:,9); % Amplitude of Cross-Polarozation YX
P4 = T1(:,10); % Phase of Cross-Polarozation YX
T_XX = txx.*exp(1i.*P1); % Transmittance of co – polarozation of XX
T_YY = tyy.*exp(1i.*P2); % Transmittance of co – polarizarion of yy
T_XY = txy.*exp(1i.*P3); % Transmittance of cross polarization of xy
T_YX = tyx.*exp(1i.*P4); % Transmittance of cross polarization of yx
TT = table(T_XX,T_YY,T_XY,T_YX);
%%%% Eigen Matrix
ii = 1:1:1002;
n = length(ii);
for i = 1:n
T = [T_XX(i,1), T_XY(i,1); T_YX(i,1), T_YY(i,1)]; % Eigen Matrix for each frequency
E = eig(T); % Eigen Values
val = [E(1,1), E(2,1)]; % Reordering the Matrix
E1(i,1) = val(:,1); % Eigen Value 1
E2(i,1) = val(:,2); % Eigen value 2
ii=ii+1;
ES1(:,1) = real(E1(:,1));
ES2(:,1) = real(E2(:,1));
ephi1(:,1) = imag(E1(:,1));
ephi2(:,1) = imag(E2(:,1));
end
%% From eigen values separate real and imaginary part.
% (Real part: Transmission coffecient, Imaginary part: Phase)
a = abs(ES1);
b = abs(ES2);
c = ephi1;
d = ephi2;
T2 = table(a,b,c,d)
figure
plot(freq,a) % Plot of freq vs real eigen value 1 and 2
plot(freq,b)
ylim([0 1])
plot(freq,ephi1,freq,ephi2) % Plot of freq vs imag eigen value 1 and 2
ylim([-0.6 0.6]) eigen values MATLAB Answers — New Questions