Tag Archives: matlab
STM32 NUCLEO fatal error: No such file or directory #include “main.h”
When I connect NUCLEO-F411RE and try to create code, the compiler gives me an error:
C:/ST_simulink/test_ert_rtw/test.h:21:18: fatal error: main.h: No such file or directory
#include "main.h"
Indeed, such a file is not created. I repeat as shown in the examples, but I can’t even start code generation. What’s my problem?When I connect NUCLEO-F411RE and try to create code, the compiler gives me an error:
C:/ST_simulink/test_ert_rtw/test.h:21:18: fatal error: main.h: No such file or directory
#include "main.h"
Indeed, such a file is not created. I repeat as shown in the examples, but I can’t even start code generation. What’s my problem? When I connect NUCLEO-F411RE and try to create code, the compiler gives me an error:
C:/ST_simulink/test_ert_rtw/test.h:21:18: fatal error: main.h: No such file or directory
#include "main.h"
Indeed, such a file is not created. I repeat as shown in the examples, but I can’t even start code generation. What’s my problem? stm32 nucleo fatal error main. MATLAB Answers — New Questions
Estimating Area Enclosed by Multiple Arcs and Discrete Points in 3D
Hello MATLAB Community,
I am working on a problem where I need to estimate the area enclosed by multiple arcs and a set of discrete points in a 3D space using MATLAB. Each arc is defined by its center, radius, orientation vectors, and rotation angle. The goal is to compute the cumulative minimum distance between each discrete point and these arcs, and use this information to estimate the enclosed area formed by the points and arcs.
Is it valid to compute the cumulative sum of minimum distances between each point and the arcs? Would this approach provide an estimation of the area enclosed by the points and arcs? Any insights or alternative approaches would be greatly appreciated.
Thank you!Hello MATLAB Community,
I am working on a problem where I need to estimate the area enclosed by multiple arcs and a set of discrete points in a 3D space using MATLAB. Each arc is defined by its center, radius, orientation vectors, and rotation angle. The goal is to compute the cumulative minimum distance between each discrete point and these arcs, and use this information to estimate the enclosed area formed by the points and arcs.
Is it valid to compute the cumulative sum of minimum distances between each point and the arcs? Would this approach provide an estimation of the area enclosed by the points and arcs? Any insights or alternative approaches would be greatly appreciated.
Thank you! Hello MATLAB Community,
I am working on a problem where I need to estimate the area enclosed by multiple arcs and a set of discrete points in a 3D space using MATLAB. Each arc is defined by its center, radius, orientation vectors, and rotation angle. The goal is to compute the cumulative minimum distance between each discrete point and these arcs, and use this information to estimate the enclosed area formed by the points and arcs.
Is it valid to compute the cumulative sum of minimum distances between each point and the arcs? Would this approach provide an estimation of the area enclosed by the points and arcs? Any insights or alternative approaches would be greatly appreciated.
Thank you! biarc curve fitting MATLAB Answers — New Questions
why this error? >> Untitledyasir Error using bvp4c (line 251) Unable to solve the collocation equations — a singular Jacobian encountered. Error in Untitledyasir (line 55) s
function slipflow
format long g
%Define all parameters
% Boundary layer thickness & stepsize
etaMin = 0;
etaMax1 = 15;
etaMax2 = 15; %15, 10
stepsize1 = etaMax1;
stepsize2 = etaMax2;
% Input for the parameters
A=1; %velocity slip
B=0.2; %thermal slip
S=2.4; %suction(2.3,2.4,2.5)
Pr=6.2; %prandtl number
lambda=-1; %stretching shrinking
a=0.01; %phil-1st nanoparticle concentration
b=0.01; %(0.01,0.05)phi2-2nd nanoparticle concentration
c=a+b; %phi-hnf concentration of hybrid nanoparticle
%%%%%%%%%%% 1st nanoparticle properties (Al2O3)%%%%%%%%%%%%
C1=765;
P1=3970;
K1=40;
B1=0.85/((10)^5);
s1=35*(10)^6; %MHD
%%%%%%%%%%% 2nd nanoparticle properties (Cu)%%%%%%%%%%%%
C2=385; %specific heat
P2=8933; %density
K2=400; %thermal conductivity
B2=1.67/((10)^5); %thermal expansion
s2=(59.6)*(10)^6; %MHD
%%%%%%%%%%% Base fluid properties %%%%%%%%%%%%
C3=4179; %specific heat
P3=997.1; %density
K3=0.613; %thermal conductivity
B3=21/((10)^5); %thermal expansion
s3=0.05; %MHD
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%multiplier%%%%%%%%%%%%%%%%%%%
H1=P1*C1; %pho*cp nanoparticle 1
H2=P2*C2; %pho*cp nanoparticle 2
H3=P3*C3; %pho*cp base fluid
H4=a*H1+b*H2+(1-c)*H3; %pho*cp hybrid nanofluid
H5=a*P1+b*P2+(1-c)*P3; %pho hybrid nanofluid
H6=1/((1-c)^2.5); % mu hybrid nanofluid / mu base fluid
H7=a*(P1*B1)+b*(P2*B2)+(1-c)*(P3*B3); % thermal expansion of hybrid nanofluid
%Kn=K3*(K1+2*K3-2*a*(K3-K1))/(K1+2*K3+a*(K3-K1)); %thermal conductivity of nanofluid
Kh=(((a*K1+b*K2)/c)+2*K3+2*(a*K1+b*K2)-2*c*K3)/(((a*K1+b*K2)/c)+2*K3-(a*K1+b*K2)-2*c*K3); %khnf/kf
H8=(((a*s1+b*s2)/c)+2*s3+2*(a*s1+b*s2)-2*c*s3)/(((a*s1+b*s2)/c)+2*s3-(a*s1+b*s2)-2*c*s3); % sigma hnf/ sigma f
D1=(H5/P3)/H6;
D3=(H7/(P3*B3))/(H5/P3); % multiplier of boundary parameter
D2= Pr*((H4/H3)/Kh);
D4=H8/(H5/P3); %multiplier MHD
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% First solution %%%%%%%%%%%%%%%%%%%
options = bvpset(‘stats’,’off’,’RelTol’,1e-10);
solinit = bvpinit (linspace (etaMin, etaMax1, stepsize1),@(x)OdeInit1(x,A,S,lambda));
sol = bvp4c(@(x,y)OdeBVP(x,y,Pr,D1,Kh,H4,H3,S), @(ya,yb)OdeBC(ya, yb, A, S, B, lambda), solinit, options);
eta = linspace (etaMin, etaMax1, stepsize1);
y= deval (sol,eta);
figure(1) %velocity profile
plot(sol.x,sol.y(2,:),’-‘)
xlabel(‘eta’)
ylabel(‘f`(eta)’)
hold on
figure(2) %temperature profile
plot(sol.x,sol.y(4,:),’-‘)
xlabel(‘eta’)
ylabel(‘theta(eta)’)
hold on
% saving the out put in text file for first solution
descris =[sol.x; sol.y];
save ‘sliphybrid_upper.txt’ descris -ascii
% Displaying the output for first solution
fprintf(‘n First solution:n’);
fprintf(‘f"(0)=%7.9fn’,y(3)); % reduced skin friction
fprintf(‘-theta(0)=%7.9fn’,-y(5)); %reduced local nusselt number
fprintf(‘Cfx=%7.9fn’,H6*(y(3))); % skin friction
fprintf(‘Nux=%7.9fn’,-Kh*y(5)); % local nusselt number
fprintf(‘n’);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% second solution %%%%%%%%%%%%%%%%%%%
options = bvpset(‘stats’,’off’,’RelTol’,1e-10);
solinit = bvpinit (linspace (etaMin, etaMax2, stepsize2),@(x)OdeInit2(x,A,S,lambda));
sol = bvp4c(@(x,y)OdeBVP(x,y,Pr,D1,Kh,H4,H3,S), @(ya,yb)OdeBC(ya, yb, A, S, B, lambda), solinit, options);
eta= linspace (etaMin, etaMax2, stepsize2);
y = deval (sol,eta);
figure(1) %velocity profile
plot(sol.x,sol.y(2,:),’–‘)
xlabel(‘eta’)
ylabel(‘f`(eta)’)
hold on
figure(2) %temperature profile
plot(sol.x,sol.y(4,:),’–‘)
xlabel(‘eta’)
ylabel(‘theta(eta)’)
hold on
% saving the out put in text file for second solution
descris=[sol.x; sol.y];
save ‘sliphybrid_lower.txt’descris -ascii
% Displaying the output for first solution
fprintf(‘nSecond solution:n’);
fprintf(‘f"(0)=%7.9fn’,y(3)); % reduced skin friction
fprintf(‘-theta(0)=%7.9fn’,-y(5)); %reduced local nusselt number
fprintf(‘Cfx=%7.9fn’,H6*(y(3))); % skin friction
fprintf(‘Nux=%7.9fn’,-Kh*y(5)); % local nusselt number
fprintf(‘n’);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end
% Define the ODE function
function f = OdeBVP(x,y,Pr,D1,Kh,H4,H3,S)
f =[y(2);y(3);(1/3)*D1*((y(2)^2)-2*(y(1)*y(3))+2*S);y(5);-2/3*(Pr*((H4/H3)/Kh)*y(1)*y(5))];
end
% Define the boundary conditions
function res = OdeBC(ya, yb, A, S, B, lambda)
res= [ya(1)-S;ya(2)-lambda;ya(4)-1;yb(3)-1;yb(4)];
end
% setting the initial guess for first solution
function v = OdeInit1(x,A,S,lambda)
v=[S+0.56;0;0;0;0];
end
% setting the initial guess for second solution
function v1 =OdeInit2(x, A, S,lambda)
v1 = [exp(-x);exp(-x);-exp(-x);-exp(-x);-exp(-x)];
endfunction slipflow
format long g
%Define all parameters
% Boundary layer thickness & stepsize
etaMin = 0;
etaMax1 = 15;
etaMax2 = 15; %15, 10
stepsize1 = etaMax1;
stepsize2 = etaMax2;
% Input for the parameters
A=1; %velocity slip
B=0.2; %thermal slip
S=2.4; %suction(2.3,2.4,2.5)
Pr=6.2; %prandtl number
lambda=-1; %stretching shrinking
a=0.01; %phil-1st nanoparticle concentration
b=0.01; %(0.01,0.05)phi2-2nd nanoparticle concentration
c=a+b; %phi-hnf concentration of hybrid nanoparticle
%%%%%%%%%%% 1st nanoparticle properties (Al2O3)%%%%%%%%%%%%
C1=765;
P1=3970;
K1=40;
B1=0.85/((10)^5);
s1=35*(10)^6; %MHD
%%%%%%%%%%% 2nd nanoparticle properties (Cu)%%%%%%%%%%%%
C2=385; %specific heat
P2=8933; %density
K2=400; %thermal conductivity
B2=1.67/((10)^5); %thermal expansion
s2=(59.6)*(10)^6; %MHD
%%%%%%%%%%% Base fluid properties %%%%%%%%%%%%
C3=4179; %specific heat
P3=997.1; %density
K3=0.613; %thermal conductivity
B3=21/((10)^5); %thermal expansion
s3=0.05; %MHD
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%multiplier%%%%%%%%%%%%%%%%%%%
H1=P1*C1; %pho*cp nanoparticle 1
H2=P2*C2; %pho*cp nanoparticle 2
H3=P3*C3; %pho*cp base fluid
H4=a*H1+b*H2+(1-c)*H3; %pho*cp hybrid nanofluid
H5=a*P1+b*P2+(1-c)*P3; %pho hybrid nanofluid
H6=1/((1-c)^2.5); % mu hybrid nanofluid / mu base fluid
H7=a*(P1*B1)+b*(P2*B2)+(1-c)*(P3*B3); % thermal expansion of hybrid nanofluid
%Kn=K3*(K1+2*K3-2*a*(K3-K1))/(K1+2*K3+a*(K3-K1)); %thermal conductivity of nanofluid
Kh=(((a*K1+b*K2)/c)+2*K3+2*(a*K1+b*K2)-2*c*K3)/(((a*K1+b*K2)/c)+2*K3-(a*K1+b*K2)-2*c*K3); %khnf/kf
H8=(((a*s1+b*s2)/c)+2*s3+2*(a*s1+b*s2)-2*c*s3)/(((a*s1+b*s2)/c)+2*s3-(a*s1+b*s2)-2*c*s3); % sigma hnf/ sigma f
D1=(H5/P3)/H6;
D3=(H7/(P3*B3))/(H5/P3); % multiplier of boundary parameter
D2= Pr*((H4/H3)/Kh);
D4=H8/(H5/P3); %multiplier MHD
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% First solution %%%%%%%%%%%%%%%%%%%
options = bvpset(‘stats’,’off’,’RelTol’,1e-10);
solinit = bvpinit (linspace (etaMin, etaMax1, stepsize1),@(x)OdeInit1(x,A,S,lambda));
sol = bvp4c(@(x,y)OdeBVP(x,y,Pr,D1,Kh,H4,H3,S), @(ya,yb)OdeBC(ya, yb, A, S, B, lambda), solinit, options);
eta = linspace (etaMin, etaMax1, stepsize1);
y= deval (sol,eta);
figure(1) %velocity profile
plot(sol.x,sol.y(2,:),’-‘)
xlabel(‘eta’)
ylabel(‘f`(eta)’)
hold on
figure(2) %temperature profile
plot(sol.x,sol.y(4,:),’-‘)
xlabel(‘eta’)
ylabel(‘theta(eta)’)
hold on
% saving the out put in text file for first solution
descris =[sol.x; sol.y];
save ‘sliphybrid_upper.txt’ descris -ascii
% Displaying the output for first solution
fprintf(‘n First solution:n’);
fprintf(‘f"(0)=%7.9fn’,y(3)); % reduced skin friction
fprintf(‘-theta(0)=%7.9fn’,-y(5)); %reduced local nusselt number
fprintf(‘Cfx=%7.9fn’,H6*(y(3))); % skin friction
fprintf(‘Nux=%7.9fn’,-Kh*y(5)); % local nusselt number
fprintf(‘n’);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% second solution %%%%%%%%%%%%%%%%%%%
options = bvpset(‘stats’,’off’,’RelTol’,1e-10);
solinit = bvpinit (linspace (etaMin, etaMax2, stepsize2),@(x)OdeInit2(x,A,S,lambda));
sol = bvp4c(@(x,y)OdeBVP(x,y,Pr,D1,Kh,H4,H3,S), @(ya,yb)OdeBC(ya, yb, A, S, B, lambda), solinit, options);
eta= linspace (etaMin, etaMax2, stepsize2);
y = deval (sol,eta);
figure(1) %velocity profile
plot(sol.x,sol.y(2,:),’–‘)
xlabel(‘eta’)
ylabel(‘f`(eta)’)
hold on
figure(2) %temperature profile
plot(sol.x,sol.y(4,:),’–‘)
xlabel(‘eta’)
ylabel(‘theta(eta)’)
hold on
% saving the out put in text file for second solution
descris=[sol.x; sol.y];
save ‘sliphybrid_lower.txt’descris -ascii
% Displaying the output for first solution
fprintf(‘nSecond solution:n’);
fprintf(‘f"(0)=%7.9fn’,y(3)); % reduced skin friction
fprintf(‘-theta(0)=%7.9fn’,-y(5)); %reduced local nusselt number
fprintf(‘Cfx=%7.9fn’,H6*(y(3))); % skin friction
fprintf(‘Nux=%7.9fn’,-Kh*y(5)); % local nusselt number
fprintf(‘n’);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end
% Define the ODE function
function f = OdeBVP(x,y,Pr,D1,Kh,H4,H3,S)
f =[y(2);y(3);(1/3)*D1*((y(2)^2)-2*(y(1)*y(3))+2*S);y(5);-2/3*(Pr*((H4/H3)/Kh)*y(1)*y(5))];
end
% Define the boundary conditions
function res = OdeBC(ya, yb, A, S, B, lambda)
res= [ya(1)-S;ya(2)-lambda;ya(4)-1;yb(3)-1;yb(4)];
end
% setting the initial guess for first solution
function v = OdeInit1(x,A,S,lambda)
v=[S+0.56;0;0;0;0];
end
% setting the initial guess for second solution
function v1 =OdeInit2(x, A, S,lambda)
v1 = [exp(-x);exp(-x);-exp(-x);-exp(-x);-exp(-x)];
end function slipflow
format long g
%Define all parameters
% Boundary layer thickness & stepsize
etaMin = 0;
etaMax1 = 15;
etaMax2 = 15; %15, 10
stepsize1 = etaMax1;
stepsize2 = etaMax2;
% Input for the parameters
A=1; %velocity slip
B=0.2; %thermal slip
S=2.4; %suction(2.3,2.4,2.5)
Pr=6.2; %prandtl number
lambda=-1; %stretching shrinking
a=0.01; %phil-1st nanoparticle concentration
b=0.01; %(0.01,0.05)phi2-2nd nanoparticle concentration
c=a+b; %phi-hnf concentration of hybrid nanoparticle
%%%%%%%%%%% 1st nanoparticle properties (Al2O3)%%%%%%%%%%%%
C1=765;
P1=3970;
K1=40;
B1=0.85/((10)^5);
s1=35*(10)^6; %MHD
%%%%%%%%%%% 2nd nanoparticle properties (Cu)%%%%%%%%%%%%
C2=385; %specific heat
P2=8933; %density
K2=400; %thermal conductivity
B2=1.67/((10)^5); %thermal expansion
s2=(59.6)*(10)^6; %MHD
%%%%%%%%%%% Base fluid properties %%%%%%%%%%%%
C3=4179; %specific heat
P3=997.1; %density
K3=0.613; %thermal conductivity
B3=21/((10)^5); %thermal expansion
s3=0.05; %MHD
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%multiplier%%%%%%%%%%%%%%%%%%%
H1=P1*C1; %pho*cp nanoparticle 1
H2=P2*C2; %pho*cp nanoparticle 2
H3=P3*C3; %pho*cp base fluid
H4=a*H1+b*H2+(1-c)*H3; %pho*cp hybrid nanofluid
H5=a*P1+b*P2+(1-c)*P3; %pho hybrid nanofluid
H6=1/((1-c)^2.5); % mu hybrid nanofluid / mu base fluid
H7=a*(P1*B1)+b*(P2*B2)+(1-c)*(P3*B3); % thermal expansion of hybrid nanofluid
%Kn=K3*(K1+2*K3-2*a*(K3-K1))/(K1+2*K3+a*(K3-K1)); %thermal conductivity of nanofluid
Kh=(((a*K1+b*K2)/c)+2*K3+2*(a*K1+b*K2)-2*c*K3)/(((a*K1+b*K2)/c)+2*K3-(a*K1+b*K2)-2*c*K3); %khnf/kf
H8=(((a*s1+b*s2)/c)+2*s3+2*(a*s1+b*s2)-2*c*s3)/(((a*s1+b*s2)/c)+2*s3-(a*s1+b*s2)-2*c*s3); % sigma hnf/ sigma f
D1=(H5/P3)/H6;
D3=(H7/(P3*B3))/(H5/P3); % multiplier of boundary parameter
D2= Pr*((H4/H3)/Kh);
D4=H8/(H5/P3); %multiplier MHD
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% First solution %%%%%%%%%%%%%%%%%%%
options = bvpset(‘stats’,’off’,’RelTol’,1e-10);
solinit = bvpinit (linspace (etaMin, etaMax1, stepsize1),@(x)OdeInit1(x,A,S,lambda));
sol = bvp4c(@(x,y)OdeBVP(x,y,Pr,D1,Kh,H4,H3,S), @(ya,yb)OdeBC(ya, yb, A, S, B, lambda), solinit, options);
eta = linspace (etaMin, etaMax1, stepsize1);
y= deval (sol,eta);
figure(1) %velocity profile
plot(sol.x,sol.y(2,:),’-‘)
xlabel(‘eta’)
ylabel(‘f`(eta)’)
hold on
figure(2) %temperature profile
plot(sol.x,sol.y(4,:),’-‘)
xlabel(‘eta’)
ylabel(‘theta(eta)’)
hold on
% saving the out put in text file for first solution
descris =[sol.x; sol.y];
save ‘sliphybrid_upper.txt’ descris -ascii
% Displaying the output for first solution
fprintf(‘n First solution:n’);
fprintf(‘f"(0)=%7.9fn’,y(3)); % reduced skin friction
fprintf(‘-theta(0)=%7.9fn’,-y(5)); %reduced local nusselt number
fprintf(‘Cfx=%7.9fn’,H6*(y(3))); % skin friction
fprintf(‘Nux=%7.9fn’,-Kh*y(5)); % local nusselt number
fprintf(‘n’);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% second solution %%%%%%%%%%%%%%%%%%%
options = bvpset(‘stats’,’off’,’RelTol’,1e-10);
solinit = bvpinit (linspace (etaMin, etaMax2, stepsize2),@(x)OdeInit2(x,A,S,lambda));
sol = bvp4c(@(x,y)OdeBVP(x,y,Pr,D1,Kh,H4,H3,S), @(ya,yb)OdeBC(ya, yb, A, S, B, lambda), solinit, options);
eta= linspace (etaMin, etaMax2, stepsize2);
y = deval (sol,eta);
figure(1) %velocity profile
plot(sol.x,sol.y(2,:),’–‘)
xlabel(‘eta’)
ylabel(‘f`(eta)’)
hold on
figure(2) %temperature profile
plot(sol.x,sol.y(4,:),’–‘)
xlabel(‘eta’)
ylabel(‘theta(eta)’)
hold on
% saving the out put in text file for second solution
descris=[sol.x; sol.y];
save ‘sliphybrid_lower.txt’descris -ascii
% Displaying the output for first solution
fprintf(‘nSecond solution:n’);
fprintf(‘f"(0)=%7.9fn’,y(3)); % reduced skin friction
fprintf(‘-theta(0)=%7.9fn’,-y(5)); %reduced local nusselt number
fprintf(‘Cfx=%7.9fn’,H6*(y(3))); % skin friction
fprintf(‘Nux=%7.9fn’,-Kh*y(5)); % local nusselt number
fprintf(‘n’);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end
% Define the ODE function
function f = OdeBVP(x,y,Pr,D1,Kh,H4,H3,S)
f =[y(2);y(3);(1/3)*D1*((y(2)^2)-2*(y(1)*y(3))+2*S);y(5);-2/3*(Pr*((H4/H3)/Kh)*y(1)*y(5))];
end
% Define the boundary conditions
function res = OdeBC(ya, yb, A, S, B, lambda)
res= [ya(1)-S;ya(2)-lambda;ya(4)-1;yb(3)-1;yb(4)];
end
% setting the initial guess for first solution
function v = OdeInit1(x,A,S,lambda)
v=[S+0.56;0;0;0;0];
end
% setting the initial guess for second solution
function v1 =OdeInit2(x, A, S,lambda)
v1 = [exp(-x);exp(-x);-exp(-x);-exp(-x);-exp(-x)];
end matlab MATLAB Answers — New Questions
Diagnostic Feature Designer Computation Error
Hello colleagues,
I plan to use Diagnostic Feature Designer for some data analysis for a predictive maintenance framework. I have an acoustic emission signal that can be imported with no issues into the Diagnostic Feature Designer, yet computation of different values is not possible. When I try to use the "Auto Feature" function, I get the following error:
The signal looks like this:
The data seems to be ok, as the same error results even if I generate a sinewave and try to use the Diagnostic Feature Deisgner with it.
Do you have any solution for this situation ?
Thank you!Hello colleagues,
I plan to use Diagnostic Feature Designer for some data analysis for a predictive maintenance framework. I have an acoustic emission signal that can be imported with no issues into the Diagnostic Feature Designer, yet computation of different values is not possible. When I try to use the "Auto Feature" function, I get the following error:
The signal looks like this:
The data seems to be ok, as the same error results even if I generate a sinewave and try to use the Diagnostic Feature Deisgner with it.
Do you have any solution for this situation ?
Thank you! Hello colleagues,
I plan to use Diagnostic Feature Designer for some data analysis for a predictive maintenance framework. I have an acoustic emission signal that can be imported with no issues into the Diagnostic Feature Designer, yet computation of different values is not possible. When I try to use the "Auto Feature" function, I get the following error:
The signal looks like this:
The data seems to be ok, as the same error results even if I generate a sinewave and try to use the Diagnostic Feature Deisgner with it.
Do you have any solution for this situation ?
Thank you! diagnostic feature designer, computation error, predictive maintenance MATLAB Answers — New Questions
[Noob here] I need help with a file exchange which uses MATLAB function
I need help with a File exchange NREL’s Solar Position Algorithm (SPA). I understand the code, but I am new to MATLAB funcitons and I do not know how to extract values from this file exchange to my program. If someone could post a simple main.m example showcasing how to extract the values (for eg. azimuth) into the main.m, it would be helpful.
Thanks in advance.I need help with a File exchange NREL’s Solar Position Algorithm (SPA). I understand the code, but I am new to MATLAB funcitons and I do not know how to extract values from this file exchange to my program. If someone could post a simple main.m example showcasing how to extract the values (for eg. azimuth) into the main.m, it would be helpful.
Thanks in advance. I need help with a File exchange NREL’s Solar Position Algorithm (SPA). I understand the code, but I am new to MATLAB funcitons and I do not know how to extract values from this file exchange to my program. If someone could post a simple main.m example showcasing how to extract the values (for eg. azimuth) into the main.m, it would be helpful.
Thanks in advance. functions MATLAB Answers — New Questions
Why step respose don’t work for first input of a MIMO? And how to use correctly feedback function for pole placement?
Hi!
I’m trying to make a step response for an unstable MIMO system. When I’m using the step function it’s only work for the second input and the first one doesn’t to anything. And also, I’m trying to make a feedback control of the system with pole placement, but I don’t really know how to write correctly the feedback function. Does anyone know what to do?
The model it’s from this study: https://www.mdpi.com/2079-9292/13/3/514#B17-electronics-13-00514
Step response:
Matlab code:
clc
clear all
close all
%% Model parameters
Mp = 0.272;
dM = 0.071;
g = 9.81;
J = 0.002;
Jw = 3.941*10^-5;
b_theta = 0.82*10^-3;
b_altha_kmke_Ra = 1.202*10^-4;
km_Ra = 1.837*10^-4;
%% Matrices for the state space model
A = [0 1 0 0;
(Mp*dM*g)/J -(b_theta)/J 0 1/J*b_altha_kmke_Ra;
0 0 0 1;
-(Mp*g*dM)/J b_theta/J 0 -(J+Jw)/(J*Jw)*b_altha_kmke_Ra];
B = [0 0;
-1/J*km_Ra 1/J;
0 0;
(J+Jw)/(J*Jw)*km_Ra -1/J];
C = [1 0 0 0;
0 1 0 0;
0 0 1 0;
0 0 0 1];
D = [0 0; 0 0;0 0;0 0];
%% Build system
sys = ss(A,B,C,0);
step(sys);
Sc = ctrb(sys);
So = obsv(sys);
%% Control
P = [-1;-2;-3;-4]*10;
K = place(A,B,P);
Alc = A-B*K;
sys_cl = ss(Alc,B,C,D);
closeLoop = feedback(sys*Alc,1);
%% Simulation
t = 0:0.001:10;
u = [ones(length(t),1) zeros(length(t),1) zeros(length(t),1) zeros(length(t),1)];
lsim(closeLoop,u,t)Hi!
I’m trying to make a step response for an unstable MIMO system. When I’m using the step function it’s only work for the second input and the first one doesn’t to anything. And also, I’m trying to make a feedback control of the system with pole placement, but I don’t really know how to write correctly the feedback function. Does anyone know what to do?
The model it’s from this study: https://www.mdpi.com/2079-9292/13/3/514#B17-electronics-13-00514
Step response:
Matlab code:
clc
clear all
close all
%% Model parameters
Mp = 0.272;
dM = 0.071;
g = 9.81;
J = 0.002;
Jw = 3.941*10^-5;
b_theta = 0.82*10^-3;
b_altha_kmke_Ra = 1.202*10^-4;
km_Ra = 1.837*10^-4;
%% Matrices for the state space model
A = [0 1 0 0;
(Mp*dM*g)/J -(b_theta)/J 0 1/J*b_altha_kmke_Ra;
0 0 0 1;
-(Mp*g*dM)/J b_theta/J 0 -(J+Jw)/(J*Jw)*b_altha_kmke_Ra];
B = [0 0;
-1/J*km_Ra 1/J;
0 0;
(J+Jw)/(J*Jw)*km_Ra -1/J];
C = [1 0 0 0;
0 1 0 0;
0 0 1 0;
0 0 0 1];
D = [0 0; 0 0;0 0;0 0];
%% Build system
sys = ss(A,B,C,0);
step(sys);
Sc = ctrb(sys);
So = obsv(sys);
%% Control
P = [-1;-2;-3;-4]*10;
K = place(A,B,P);
Alc = A-B*K;
sys_cl = ss(Alc,B,C,D);
closeLoop = feedback(sys*Alc,1);
%% Simulation
t = 0:0.001:10;
u = [ones(length(t),1) zeros(length(t),1) zeros(length(t),1) zeros(length(t),1)];
lsim(closeLoop,u,t) Hi!
I’m trying to make a step response for an unstable MIMO system. When I’m using the step function it’s only work for the second input and the first one doesn’t to anything. And also, I’m trying to make a feedback control of the system with pole placement, but I don’t really know how to write correctly the feedback function. Does anyone know what to do?
The model it’s from this study: https://www.mdpi.com/2079-9292/13/3/514#B17-electronics-13-00514
Step response:
Matlab code:
clc
clear all
close all
%% Model parameters
Mp = 0.272;
dM = 0.071;
g = 9.81;
J = 0.002;
Jw = 3.941*10^-5;
b_theta = 0.82*10^-3;
b_altha_kmke_Ra = 1.202*10^-4;
km_Ra = 1.837*10^-4;
%% Matrices for the state space model
A = [0 1 0 0;
(Mp*dM*g)/J -(b_theta)/J 0 1/J*b_altha_kmke_Ra;
0 0 0 1;
-(Mp*g*dM)/J b_theta/J 0 -(J+Jw)/(J*Jw)*b_altha_kmke_Ra];
B = [0 0;
-1/J*km_Ra 1/J;
0 0;
(J+Jw)/(J*Jw)*km_Ra -1/J];
C = [1 0 0 0;
0 1 0 0;
0 0 1 0;
0 0 0 1];
D = [0 0; 0 0;0 0;0 0];
%% Build system
sys = ss(A,B,C,0);
step(sys);
Sc = ctrb(sys);
So = obsv(sys);
%% Control
P = [-1;-2;-3;-4]*10;
K = place(A,B,P);
Alc = A-B*K;
sys_cl = ss(Alc,B,C,D);
closeLoop = feedback(sys*Alc,1);
%% Simulation
t = 0:0.001:10;
u = [ones(length(t),1) zeros(length(t),1) zeros(length(t),1) zeros(length(t),1)];
lsim(closeLoop,u,t) matlab, equation, matrices, control MATLAB Answers — New Questions
System of nonliner equations with symbolic variables
Hi there,
I would like to ask you how to solve a system of nonlinear equations while using symbolic variables.
I have two equations that I need to solve:
eqT = 10*lamT^13*lamZ^13 – 10/lamT^13 – 10*lamT^2*lamZ
eqZ = 10*lamT^13*lamZ^13 – 10/lamZ^13 – 5*lamT^2*lamZ
where lamT and lamZ are symbolic.
I was trying to search for it and most times I have found to use matlabFunction and fsolve. But it doesn’t work for me. Probably I understand it wrong or maybe I am doing another mistake.
fun = matlabFunction(eqT, eqZ)
eqsol = fsolve(fun,[1 1])
Can you please help me and explain me what I am doing wrong.
Thank you very much
P.S.: it is not possible not to use symbolic variables. They are used for some derivations before. Also it is not possible to rewrite the equations manually because they are to be solved many times in for cycle with different constants.Hi there,
I would like to ask you how to solve a system of nonlinear equations while using symbolic variables.
I have two equations that I need to solve:
eqT = 10*lamT^13*lamZ^13 – 10/lamT^13 – 10*lamT^2*lamZ
eqZ = 10*lamT^13*lamZ^13 – 10/lamZ^13 – 5*lamT^2*lamZ
where lamT and lamZ are symbolic.
I was trying to search for it and most times I have found to use matlabFunction and fsolve. But it doesn’t work for me. Probably I understand it wrong or maybe I am doing another mistake.
fun = matlabFunction(eqT, eqZ)
eqsol = fsolve(fun,[1 1])
Can you please help me and explain me what I am doing wrong.
Thank you very much
P.S.: it is not possible not to use symbolic variables. They are used for some derivations before. Also it is not possible to rewrite the equations manually because they are to be solved many times in for cycle with different constants. Hi there,
I would like to ask you how to solve a system of nonlinear equations while using symbolic variables.
I have two equations that I need to solve:
eqT = 10*lamT^13*lamZ^13 – 10/lamT^13 – 10*lamT^2*lamZ
eqZ = 10*lamT^13*lamZ^13 – 10/lamZ^13 – 5*lamT^2*lamZ
where lamT and lamZ are symbolic.
I was trying to search for it and most times I have found to use matlabFunction and fsolve. But it doesn’t work for me. Probably I understand it wrong or maybe I am doing another mistake.
fun = matlabFunction(eqT, eqZ)
eqsol = fsolve(fun,[1 1])
Can you please help me and explain me what I am doing wrong.
Thank you very much
P.S.: it is not possible not to use symbolic variables. They are used for some derivations before. Also it is not possible to rewrite the equations manually because they are to be solved many times in for cycle with different constants. symbolic, fsolve MATLAB Answers — New Questions
Solving symbolic array.
I am working with symbolic vector of 1xN size. The vector contains N eqations in the from of
X == a + b + c
Y == X*(d + e + f)
Z == Y + X
I am suing subs to substitute the coefficients a b c d e f with numeric values. The result is in the form of
X == g
Y ==X*h
Z == Y +X
It sould be quite straigh forward to solve for Z since all variables are numeric, but for crying out loud I cannot make matlab to solve for Z.
Any ideas?I am working with symbolic vector of 1xN size. The vector contains N eqations in the from of
X == a + b + c
Y == X*(d + e + f)
Z == Y + X
I am suing subs to substitute the coefficients a b c d e f with numeric values. The result is in the form of
X == g
Y ==X*h
Z == Y +X
It sould be quite straigh forward to solve for Z since all variables are numeric, but for crying out loud I cannot make matlab to solve for Z.
Any ideas? I am working with symbolic vector of 1xN size. The vector contains N eqations in the from of
X == a + b + c
Y == X*(d + e + f)
Z == Y + X
I am suing subs to substitute the coefficients a b c d e f with numeric values. The result is in the form of
X == g
Y ==X*h
Z == Y +X
It sould be quite straigh forward to solve for Z since all variables are numeric, but for crying out loud I cannot make matlab to solve for Z.
Any ideas? equation, solve MATLAB Answers — New Questions
HOW TO ADD ONE COLUMN BASED ON ANOTHER COLUMN
I have a file containing some columns.
hru sub year mon area gw_rchrg
1 1 2016 1 61 1.87
2 1 2016 1 233 2.91
3 1 2016 1 345 5.45
4 1 2016 1 600 1.23
5 1 2016 1 400 2.67
6 1 2016 1 235 1.34
7 2 2016 1 123 3.67
8 2 2016 1 178 4.78
9 2 2016 1 345 1.56
10 2 2016 1 430 2.67
11 2 2016 1 250 1.12
12 2 2016 1 278 2.12
I have a excel file which has 7 colums. In colum 2 there are rows containing 1 and 2. I want to do some operations.
The second column as 1 value. I want to multiply the values of column 5 and column 6 and add them according to 1 value if column 2. Similarly do it for 2 values of column 2. If there is any code for this?I have a file containing some columns.
hru sub year mon area gw_rchrg
1 1 2016 1 61 1.87
2 1 2016 1 233 2.91
3 1 2016 1 345 5.45
4 1 2016 1 600 1.23
5 1 2016 1 400 2.67
6 1 2016 1 235 1.34
7 2 2016 1 123 3.67
8 2 2016 1 178 4.78
9 2 2016 1 345 1.56
10 2 2016 1 430 2.67
11 2 2016 1 250 1.12
12 2 2016 1 278 2.12
I have a excel file which has 7 colums. In colum 2 there are rows containing 1 and 2. I want to do some operations.
The second column as 1 value. I want to multiply the values of column 5 and column 6 and add them according to 1 value if column 2. Similarly do it for 2 values of column 2. If there is any code for this? I have a file containing some columns.
hru sub year mon area gw_rchrg
1 1 2016 1 61 1.87
2 1 2016 1 233 2.91
3 1 2016 1 345 5.45
4 1 2016 1 600 1.23
5 1 2016 1 400 2.67
6 1 2016 1 235 1.34
7 2 2016 1 123 3.67
8 2 2016 1 178 4.78
9 2 2016 1 345 1.56
10 2 2016 1 430 2.67
11 2 2016 1 250 1.12
12 2 2016 1 278 2.12
I have a excel file which has 7 colums. In colum 2 there are rows containing 1 and 2. I want to do some operations.
The second column as 1 value. I want to multiply the values of column 5 and column 6 and add them according to 1 value if column 2. Similarly do it for 2 values of column 2. If there is any code for this? column, row MATLAB Answers — New Questions
Ncorr post Fail help
Hello Friends,
I apologize in advance if I skip some protocol to post my problem, but I am new to matlab and the forum. After long attempts to make Ncorr_Post run, I decided to consult by this means.
To summarize, I have already processed images with the add on Ncorr, I managed to realize that even the results obtained were saved correctly, generating some workspace with the field of displacement and deformations for each image that allow plotting graphically as seen in the ncorr generally. But, what I am really interested in is not the displacement field itself, but to extract the linear displacement from one point to another (that is, a column with the displacement data of the material, to be able to compare with the displacement delivered by the testing machine), the Ncorr_Post extension does exactly this by the name of "virtual extensometer". The problem is that when I load the data from the Ncorr and the .mat file that it generates, it gives me an error, if I load the .mat file the problem is to recognize the dimension of the array and gives the following:
Index exceeds matrix dimensions.
Error in calculateOtherQuantities (line 3)
for i = 1:plottingData(1).nFiles
Error in run (line 91)
evalin(‘caller’, strcat(script, ‘;’));
Error in ncorr_post>pushbutton9_Callback (line 527)
run calculateOtherQuantities
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in ncorr_post (line 45)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)ncorr_post(‘pushbutton9_Callback’,hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
On the other hand, when I load the data from the Ncorr, it seems that it does not communicate with it, saying the following:
Error using evalin
Undefined function or variable ‘handles_ncorr’.
Error in getNcorrData_v1_2 (line 16)
handles_ncorr = evalin(‘base’,’handles_ncorr’);
Error in run (line 91)
evalin(‘caller’, strcat(script, ‘;’));
Error in ncorr_post>pushbutton8_Callback (line 125)
run getNcorrData_v1_2
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in ncorr_post (line 45)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)ncorr_post(‘pushbutton8_Callback’,hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
I don’t know if I am using Ncorr_Post wrong, but I have already tried with all the versions, even Ncorr. The only thing that I had to do was to try other versions of matlab, but I don’t know if this will work.
I hope you can help me to solve this, I would be deeply grateful.
Greetings and thanks in advanceHello Friends,
I apologize in advance if I skip some protocol to post my problem, but I am new to matlab and the forum. After long attempts to make Ncorr_Post run, I decided to consult by this means.
To summarize, I have already processed images with the add on Ncorr, I managed to realize that even the results obtained were saved correctly, generating some workspace with the field of displacement and deformations for each image that allow plotting graphically as seen in the ncorr generally. But, what I am really interested in is not the displacement field itself, but to extract the linear displacement from one point to another (that is, a column with the displacement data of the material, to be able to compare with the displacement delivered by the testing machine), the Ncorr_Post extension does exactly this by the name of "virtual extensometer". The problem is that when I load the data from the Ncorr and the .mat file that it generates, it gives me an error, if I load the .mat file the problem is to recognize the dimension of the array and gives the following:
Index exceeds matrix dimensions.
Error in calculateOtherQuantities (line 3)
for i = 1:plottingData(1).nFiles
Error in run (line 91)
evalin(‘caller’, strcat(script, ‘;’));
Error in ncorr_post>pushbutton9_Callback (line 527)
run calculateOtherQuantities
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in ncorr_post (line 45)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)ncorr_post(‘pushbutton9_Callback’,hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
On the other hand, when I load the data from the Ncorr, it seems that it does not communicate with it, saying the following:
Error using evalin
Undefined function or variable ‘handles_ncorr’.
Error in getNcorrData_v1_2 (line 16)
handles_ncorr = evalin(‘base’,’handles_ncorr’);
Error in run (line 91)
evalin(‘caller’, strcat(script, ‘;’));
Error in ncorr_post>pushbutton8_Callback (line 125)
run getNcorrData_v1_2
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in ncorr_post (line 45)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)ncorr_post(‘pushbutton8_Callback’,hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
I don’t know if I am using Ncorr_Post wrong, but I have already tried with all the versions, even Ncorr. The only thing that I had to do was to try other versions of matlab, but I don’t know if this will work.
I hope you can help me to solve this, I would be deeply grateful.
Greetings and thanks in advance Hello Friends,
I apologize in advance if I skip some protocol to post my problem, but I am new to matlab and the forum. After long attempts to make Ncorr_Post run, I decided to consult by this means.
To summarize, I have already processed images with the add on Ncorr, I managed to realize that even the results obtained were saved correctly, generating some workspace with the field of displacement and deformations for each image that allow plotting graphically as seen in the ncorr generally. But, what I am really interested in is not the displacement field itself, but to extract the linear displacement from one point to another (that is, a column with the displacement data of the material, to be able to compare with the displacement delivered by the testing machine), the Ncorr_Post extension does exactly this by the name of "virtual extensometer". The problem is that when I load the data from the Ncorr and the .mat file that it generates, it gives me an error, if I load the .mat file the problem is to recognize the dimension of the array and gives the following:
Index exceeds matrix dimensions.
Error in calculateOtherQuantities (line 3)
for i = 1:plottingData(1).nFiles
Error in run (line 91)
evalin(‘caller’, strcat(script, ‘;’));
Error in ncorr_post>pushbutton9_Callback (line 527)
run calculateOtherQuantities
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in ncorr_post (line 45)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)ncorr_post(‘pushbutton9_Callback’,hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
On the other hand, when I load the data from the Ncorr, it seems that it does not communicate with it, saying the following:
Error using evalin
Undefined function or variable ‘handles_ncorr’.
Error in getNcorrData_v1_2 (line 16)
handles_ncorr = evalin(‘base’,’handles_ncorr’);
Error in run (line 91)
evalin(‘caller’, strcat(script, ‘;’));
Error in ncorr_post>pushbutton8_Callback (line 125)
run getNcorrData_v1_2
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in ncorr_post (line 45)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)ncorr_post(‘pushbutton8_Callback’,hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
I don’t know if I am using Ncorr_Post wrong, but I have already tried with all the versions, even Ncorr. The only thing that I had to do was to try other versions of matlab, but I don’t know if this will work.
I hope you can help me to solve this, I would be deeply grateful.
Greetings and thanks in advance ncorr, dic MATLAB Answers — New Questions
How to assign pair of values to a single aeeay in the matrix using two different vectors
fsine=50e6:0.4e9:3e9;
Vp=0:0.5:3;
I need to form a matrix such that columns correspons to different Vp for a single fsine.
the first column should be for fsine=50e6 for all values for Vp and second column should be fsine=50e6+0.1e9 for all values in Vp
The final vector should be have 7 rows and 8 columns.fsine=50e6:0.4e9:3e9;
Vp=0:0.5:3;
I need to form a matrix such that columns correspons to different Vp for a single fsine.
the first column should be for fsine=50e6 for all values for Vp and second column should be fsine=50e6+0.1e9 for all values in Vp
The final vector should be have 7 rows and 8 columns. fsine=50e6:0.4e9:3e9;
Vp=0:0.5:3;
I need to form a matrix such that columns correspons to different Vp for a single fsine.
the first column should be for fsine=50e6 for all values for Vp and second column should be fsine=50e6+0.1e9 for all values in Vp
The final vector should be have 7 rows and 8 columns. matrix MATLAB Answers — New Questions
Weights and Biases Not Updating in Custom MATLAB dlnetwork Training Loop
Hello MATLAB Community,
I am currently working on training a custom autoencoder network using MATLAB’s dlnetwork framework. Despite setting up a manual training loop with gradient computation and parameter updates using adamupdate, I’ve observed that the weights and biases of the network do not change between iterations. Additionally, all biases remain zero throughout training. I am using Matlab R2024a. Here are the relevant parts of my code:
trailingAvgG = [];
trailingAvgSqG = [];
trailingAvgR = [];
trailingAvgSqR = [];
miniBatchSize = 600;
learnRate = 0.01;
layers = [
sequenceInputLayer(1,MinLength = 2048)
modwtLayer(‘Level’,5,’IncludeLowpass’,false,’SelectedLevels’,2:5,"Wavelet","sym2")
flattenLayer
convolution1dLayer(128,8,Padding="same",Stride=8)
batchNormalizationLayer()
tanhLayer
maxPooling1dLayer(2,Padding="same")
convolution1dLayer(32,8,Padding="same",Stride=4)
batchNormalizationLayer
tanhLayer
maxPooling1dLayer(2,Padding="same")
transposedConv1dLayer(32,8,Cropping="same",Stride=4)
tanhLayer
transposedConv1dLayer(128,8,Cropping="same",Stride=8)
tanhLayer
bilstmLayer(8)
fullyConnectedLayer(8)
dropoutLayer(0.2)
fullyConnectedLayer(4)
dropoutLayer(0.2)
fullyConnectedLayer(1)];
net = dlnetwork(layers);
numEpochs = 200;
%dataMat = 1x2048x22275
dldata = arrayDatastore(dataMat,IterationDimension=3);
mbq = minibatchqueue(dldata,…
MiniBatchSize=miniBatchSize, …
OutputEnvironment= "cpu");
iteration = 0;
for epoch = 1:numEpochs
shuffle(mbq);
while hasdata(mbq)
iteration = iteration+1;
[XTrain] = next(mbq);
XTrain = dlarray(XTrain,"TBC"); % 1(C)x600(B)x2048(T)
[datafromRNN,lossR] = RNN_model(XTrain,net);
[gradientsR] = dlfeval(@gradientFunction,mean(lossR), net);
[net,trailingAvgR,trailingAvgSqR] = adamupdate(net,gradientsR, …
trailingAvgR,trailingAvgSqR,iteration,learnRate);
disp([‘Iteration ‘, num2str(iteration), ‘, Loss: ‘, num2str(extractdata(lossR))]);
end
end
function [gradientsR] = gradientFunction(lossR, net)
gradientsR = dlgradient(lossR, net.Learnables);
end
function [datafromRNN,loss] = RNN_model(data,net)
z = data;
[coder, last] = forward(net, z, ‘Outputs’, {‘maxpool1d_2’, ‘fc_3’});
loss = mse(last,z);
end
Questions:
Why are the weights and biases not updating, and why do the biases remain zero?
How can I ensure that the gradients computed are correct and being applied effectively?
Are there any specific settings or modifications I should consider to resolve this issue?
Any insights or suggestions would be greatly appreciated!Hello MATLAB Community,
I am currently working on training a custom autoencoder network using MATLAB’s dlnetwork framework. Despite setting up a manual training loop with gradient computation and parameter updates using adamupdate, I’ve observed that the weights and biases of the network do not change between iterations. Additionally, all biases remain zero throughout training. I am using Matlab R2024a. Here are the relevant parts of my code:
trailingAvgG = [];
trailingAvgSqG = [];
trailingAvgR = [];
trailingAvgSqR = [];
miniBatchSize = 600;
learnRate = 0.01;
layers = [
sequenceInputLayer(1,MinLength = 2048)
modwtLayer(‘Level’,5,’IncludeLowpass’,false,’SelectedLevels’,2:5,"Wavelet","sym2")
flattenLayer
convolution1dLayer(128,8,Padding="same",Stride=8)
batchNormalizationLayer()
tanhLayer
maxPooling1dLayer(2,Padding="same")
convolution1dLayer(32,8,Padding="same",Stride=4)
batchNormalizationLayer
tanhLayer
maxPooling1dLayer(2,Padding="same")
transposedConv1dLayer(32,8,Cropping="same",Stride=4)
tanhLayer
transposedConv1dLayer(128,8,Cropping="same",Stride=8)
tanhLayer
bilstmLayer(8)
fullyConnectedLayer(8)
dropoutLayer(0.2)
fullyConnectedLayer(4)
dropoutLayer(0.2)
fullyConnectedLayer(1)];
net = dlnetwork(layers);
numEpochs = 200;
%dataMat = 1x2048x22275
dldata = arrayDatastore(dataMat,IterationDimension=3);
mbq = minibatchqueue(dldata,…
MiniBatchSize=miniBatchSize, …
OutputEnvironment= "cpu");
iteration = 0;
for epoch = 1:numEpochs
shuffle(mbq);
while hasdata(mbq)
iteration = iteration+1;
[XTrain] = next(mbq);
XTrain = dlarray(XTrain,"TBC"); % 1(C)x600(B)x2048(T)
[datafromRNN,lossR] = RNN_model(XTrain,net);
[gradientsR] = dlfeval(@gradientFunction,mean(lossR), net);
[net,trailingAvgR,trailingAvgSqR] = adamupdate(net,gradientsR, …
trailingAvgR,trailingAvgSqR,iteration,learnRate);
disp([‘Iteration ‘, num2str(iteration), ‘, Loss: ‘, num2str(extractdata(lossR))]);
end
end
function [gradientsR] = gradientFunction(lossR, net)
gradientsR = dlgradient(lossR, net.Learnables);
end
function [datafromRNN,loss] = RNN_model(data,net)
z = data;
[coder, last] = forward(net, z, ‘Outputs’, {‘maxpool1d_2’, ‘fc_3’});
loss = mse(last,z);
end
Questions:
Why are the weights and biases not updating, and why do the biases remain zero?
How can I ensure that the gradients computed are correct and being applied effectively?
Are there any specific settings or modifications I should consider to resolve this issue?
Any insights or suggestions would be greatly appreciated! Hello MATLAB Community,
I am currently working on training a custom autoencoder network using MATLAB’s dlnetwork framework. Despite setting up a manual training loop with gradient computation and parameter updates using adamupdate, I’ve observed that the weights and biases of the network do not change between iterations. Additionally, all biases remain zero throughout training. I am using Matlab R2024a. Here are the relevant parts of my code:
trailingAvgG = [];
trailingAvgSqG = [];
trailingAvgR = [];
trailingAvgSqR = [];
miniBatchSize = 600;
learnRate = 0.01;
layers = [
sequenceInputLayer(1,MinLength = 2048)
modwtLayer(‘Level’,5,’IncludeLowpass’,false,’SelectedLevels’,2:5,"Wavelet","sym2")
flattenLayer
convolution1dLayer(128,8,Padding="same",Stride=8)
batchNormalizationLayer()
tanhLayer
maxPooling1dLayer(2,Padding="same")
convolution1dLayer(32,8,Padding="same",Stride=4)
batchNormalizationLayer
tanhLayer
maxPooling1dLayer(2,Padding="same")
transposedConv1dLayer(32,8,Cropping="same",Stride=4)
tanhLayer
transposedConv1dLayer(128,8,Cropping="same",Stride=8)
tanhLayer
bilstmLayer(8)
fullyConnectedLayer(8)
dropoutLayer(0.2)
fullyConnectedLayer(4)
dropoutLayer(0.2)
fullyConnectedLayer(1)];
net = dlnetwork(layers);
numEpochs = 200;
%dataMat = 1x2048x22275
dldata = arrayDatastore(dataMat,IterationDimension=3);
mbq = minibatchqueue(dldata,…
MiniBatchSize=miniBatchSize, …
OutputEnvironment= "cpu");
iteration = 0;
for epoch = 1:numEpochs
shuffle(mbq);
while hasdata(mbq)
iteration = iteration+1;
[XTrain] = next(mbq);
XTrain = dlarray(XTrain,"TBC"); % 1(C)x600(B)x2048(T)
[datafromRNN,lossR] = RNN_model(XTrain,net);
[gradientsR] = dlfeval(@gradientFunction,mean(lossR), net);
[net,trailingAvgR,trailingAvgSqR] = adamupdate(net,gradientsR, …
trailingAvgR,trailingAvgSqR,iteration,learnRate);
disp([‘Iteration ‘, num2str(iteration), ‘, Loss: ‘, num2str(extractdata(lossR))]);
end
end
function [gradientsR] = gradientFunction(lossR, net)
gradientsR = dlgradient(lossR, net.Learnables);
end
function [datafromRNN,loss] = RNN_model(data,net)
z = data;
[coder, last] = forward(net, z, ‘Outputs’, {‘maxpool1d_2’, ‘fc_3’});
loss = mse(last,z);
end
Questions:
Why are the weights and biases not updating, and why do the biases remain zero?
How can I ensure that the gradients computed are correct and being applied effectively?
Are there any specific settings or modifications I should consider to resolve this issue?
Any insights or suggestions would be greatly appreciated! deep learning, machine learning MATLAB Answers — New Questions
Saving code as image
I have coded a program in Matlab editor, but now i need to add it as an image in my word document. Pls tell me how to do it.I have coded a program in Matlab editor, but now i need to add it as an image in my word document. Pls tell me how to do it. I have coded a program in Matlab editor, but now i need to add it as an image in my word document. Pls tell me how to do it. saving MATLAB Answers — New Questions
This error message was encountered while using the GeoPIV RG software to calculate the particle displacement.
Error using dataread
Trouble reading floating point number from file (row 1, field 2) ==>
Error in textread (line 171)
[varargout{1:nlhs}]=dataread(‘file’,varargin{:}); %#ok<REMFF1>
Error in geoPIV_RG_runError using dataread
Trouble reading floating point number from file (row 1, field 2) ==>
Error in textread (line 171)
[varargout{1:nlhs}]=dataread(‘file’,varargin{:}); %#ok<REMFF1>
Error in geoPIV_RG_run Error using dataread
Trouble reading floating point number from file (row 1, field 2) ==>
Error in textread (line 171)
[varargout{1:nlhs}]=dataread(‘file’,varargin{:}); %#ok<REMFF1>
Error in geoPIV_RG_run geopiv rg, particle displacement MATLAB Answers — New Questions
iterate over a vector in a for loop
I am trying to loop through a matrix – my model has no problem looping through the bandwidths "bw" but i get an error when looping through the priors, because prior has vectors of values
the input of prior works in the format when not using a for loop…
prior = [0.427,0.226,0.347];
but i want the model to run through 3 different types of prior probabilities, as below
the error i get is: Error using classreg.learning.classif.FullClassificationModel.processPrior (line 264)
Prior probabilities must be a vector of length 3.
when i print prior i get
priors =
0.3300 0.3300 0.3300
0.4270 0.2260 0.3470
0.2000 0.2000 0.6000
bandwidths = [0.2, 0.5, 1];
priors = [0.33 0.33 0.33; 0.427 0.226 0.347; 0.2 0.2 0.6];
global mymatrix
for f=1:length(bandwidths);
for l=1:length(priors);
bw= bandwidths(f);
p = priors(l)
Mdl = fitcnb(x_train_crossval,y_labels_train_crossval,’ClassNames’, class_names,’PredictorNames’,predictor_names,’Prior’,p,’Width’,bw);I am trying to loop through a matrix – my model has no problem looping through the bandwidths "bw" but i get an error when looping through the priors, because prior has vectors of values
the input of prior works in the format when not using a for loop…
prior = [0.427,0.226,0.347];
but i want the model to run through 3 different types of prior probabilities, as below
the error i get is: Error using classreg.learning.classif.FullClassificationModel.processPrior (line 264)
Prior probabilities must be a vector of length 3.
when i print prior i get
priors =
0.3300 0.3300 0.3300
0.4270 0.2260 0.3470
0.2000 0.2000 0.6000
bandwidths = [0.2, 0.5, 1];
priors = [0.33 0.33 0.33; 0.427 0.226 0.347; 0.2 0.2 0.6];
global mymatrix
for f=1:length(bandwidths);
for l=1:length(priors);
bw= bandwidths(f);
p = priors(l)
Mdl = fitcnb(x_train_crossval,y_labels_train_crossval,’ClassNames’, class_names,’PredictorNames’,predictor_names,’Prior’,p,’Width’,bw); I am trying to loop through a matrix – my model has no problem looping through the bandwidths "bw" but i get an error when looping through the priors, because prior has vectors of values
the input of prior works in the format when not using a for loop…
prior = [0.427,0.226,0.347];
but i want the model to run through 3 different types of prior probabilities, as below
the error i get is: Error using classreg.learning.classif.FullClassificationModel.processPrior (line 264)
Prior probabilities must be a vector of length 3.
when i print prior i get
priors =
0.3300 0.3300 0.3300
0.4270 0.2260 0.3470
0.2000 0.2000 0.6000
bandwidths = [0.2, 0.5, 1];
priors = [0.33 0.33 0.33; 0.427 0.226 0.347; 0.2 0.2 0.6];
global mymatrix
for f=1:length(bandwidths);
for l=1:length(priors);
bw= bandwidths(f);
p = priors(l)
Mdl = fitcnb(x_train_crossval,y_labels_train_crossval,’ClassNames’, class_names,’PredictorNames’,predictor_names,’Prior’,p,’Width’,bw); forloop, iterate MATLAB Answers — New Questions
Como obtener la función de transferencia en controles
Cuál es la instrucción para obtener la función de transferenciaCuál es la instrucción para obtener la función de transferencia Cuál es la instrucción para obtener la función de transferencia instrucción MATLAB Answers — New Questions
Tcpclient function very slow.
Here is the example tcpclient I use. I it takes 2.3 seconds to send the command. Can anyone let me know what I am doing wrong.
commandstr = ‘echo’
tic
t = tcpclient(‘localhost’,Portnumber);
t.ByteOrder = "big-endian";
% configureTerminator(t,"CR/LF")
write(t ,length(commandstr),’uint32′);
write(t,commandstr);
BytesToRead = read(t,1,’uint32′);
B = read(t,BytesToRead,’string’);
command_sent = strip(B);
clear t
toc
Elapsed time is 2.353485 seconds.Here is the example tcpclient I use. I it takes 2.3 seconds to send the command. Can anyone let me know what I am doing wrong.
commandstr = ‘echo’
tic
t = tcpclient(‘localhost’,Portnumber);
t.ByteOrder = "big-endian";
% configureTerminator(t,"CR/LF")
write(t ,length(commandstr),’uint32′);
write(t,commandstr);
BytesToRead = read(t,1,’uint32′);
B = read(t,BytesToRead,’string’);
command_sent = strip(B);
clear t
toc
Elapsed time is 2.353485 seconds. Here is the example tcpclient I use. I it takes 2.3 seconds to send the command. Can anyone let me know what I am doing wrong.
commandstr = ‘echo’
tic
t = tcpclient(‘localhost’,Portnumber);
t.ByteOrder = "big-endian";
% configureTerminator(t,"CR/LF")
write(t ,length(commandstr),’uint32′);
write(t,commandstr);
BytesToRead = read(t,1,’uint32′);
B = read(t,BytesToRead,’string’);
command_sent = strip(B);
clear t
toc
Elapsed time is 2.353485 seconds. tcpclient MATLAB Answers — New Questions
ROS2 Subscriber Callback Function Arguments for Code Generation
I need to pass additional variables to my ROS2 subscriber callback function. I am trying to follow the help file explicity, which states:
"callback can be a single function handle or a cell array. The first element of the cell array needs to be a function handle or a string containing the name of a function. The remaining elements of the cell array can be arbitrary user data that will be passed to the callback function."
Based on this I built the following function to run my ROS2 subscriber node:
function [] = multirate_tag_sorter_test_simple()
node = ros2node("myNode",0);
myMsg = ros2message("builtin_interfaces/Time");
tableA = struct2table(myMsg, ‘AsArray’, true);
%% THE CREATING PROBLEMS —V
mySub = ros2subscriber(node,"/myTopic","builtin_interfaces/Time",{@receivedMessageCallback,tableA});
%
while true
fprintf(‘Waiting for messages to arrive…n’)
pause(5);
end
function receivedMessageCallback(src,msg,inputTable)
fprintf(‘MESSAGE RECEIVED!’);
end
end
but this generates error for code generation (see end of this question). The callback works fine if I don’t try to pass additional arguments (i.e. mySub = ros2subscriber(node,"/myTopic","builtin_interfaces/Time",@receivedMessageCallback). The issue I am having is that when I try to specify the callback as {@receivedMessageCallback,tableA}, I get the error message shown at the bottom of this message.
The error message states that it expects a parameter name. It seems that Coder doesn’t know that {@func,var1} is a callback function declaration. Unfortunately, callback functions are not listed in the nave-value pair list in the help file for ros2subscriber. I even tried setting the property manually after the subscriber intialization,
mySub = ros2subscriber(node,"/myTopic","builtin_interfaces/Time")
mySub.NewMessageFnc = {@receivedMessageCallback,tableA};
but got an error stating that NewMessageFnc is immutable, so it must be specified in the ros2subscriber call. Is this a bug with code generation for these callbacks, or am I doing something wrong? If it is a bug, is there a work around? Thanks.
The code generation script
cfg = coder.config(‘exe’);
cfg.Hardware = coder.hardware(‘Robot Operating System 2 (ROS 2)’);
cfg.Hardware.BuildAction = ‘Build and load’;
cfg.Hardware.RemoteDeviceAddress = ‘XXX.XXX.XXX.XXX’;
cfg.Hardware.RemoteDeviceUsername = ‘XXXX’;
cfg.Hardware.RemoteDevicePassword = ‘XXXXX’;
cfg.Hardware.DeployTo = ‘Remote Device’;
cfg.Hardware.ROS2Folder = ‘/opt/ros/galactic’;
cfg.Hardware.ROS2Workspace = ‘~/uavrt_ws’;
cfg.HardwareImplementation.ProdHWDeviceType = ‘Intel->x86-64 (Linux 64)’;
cfg.RuntimeChecks = true;%Disable for final deployments.
codegen multirate_tag_sorter_test_simple -args {} -config cfg
The error message
>> multirate_tag_sorter_test_codegen_script
??? Expected a parameter name.
Error in ==> multirate_tag_sorter_test_simple Line: 7 Column: 9
Code generation failed: View Error Report
Error using codegen
Error in multirate_tag_sorter_test_codegen_script (line 22)
codegen multirate_tag_sorter_test_simple -args {} -config cfgI need to pass additional variables to my ROS2 subscriber callback function. I am trying to follow the help file explicity, which states:
"callback can be a single function handle or a cell array. The first element of the cell array needs to be a function handle or a string containing the name of a function. The remaining elements of the cell array can be arbitrary user data that will be passed to the callback function."
Based on this I built the following function to run my ROS2 subscriber node:
function [] = multirate_tag_sorter_test_simple()
node = ros2node("myNode",0);
myMsg = ros2message("builtin_interfaces/Time");
tableA = struct2table(myMsg, ‘AsArray’, true);
%% THE CREATING PROBLEMS —V
mySub = ros2subscriber(node,"/myTopic","builtin_interfaces/Time",{@receivedMessageCallback,tableA});
%
while true
fprintf(‘Waiting for messages to arrive…n’)
pause(5);
end
function receivedMessageCallback(src,msg,inputTable)
fprintf(‘MESSAGE RECEIVED!’);
end
end
but this generates error for code generation (see end of this question). The callback works fine if I don’t try to pass additional arguments (i.e. mySub = ros2subscriber(node,"/myTopic","builtin_interfaces/Time",@receivedMessageCallback). The issue I am having is that when I try to specify the callback as {@receivedMessageCallback,tableA}, I get the error message shown at the bottom of this message.
The error message states that it expects a parameter name. It seems that Coder doesn’t know that {@func,var1} is a callback function declaration. Unfortunately, callback functions are not listed in the nave-value pair list in the help file for ros2subscriber. I even tried setting the property manually after the subscriber intialization,
mySub = ros2subscriber(node,"/myTopic","builtin_interfaces/Time")
mySub.NewMessageFnc = {@receivedMessageCallback,tableA};
but got an error stating that NewMessageFnc is immutable, so it must be specified in the ros2subscriber call. Is this a bug with code generation for these callbacks, or am I doing something wrong? If it is a bug, is there a work around? Thanks.
The code generation script
cfg = coder.config(‘exe’);
cfg.Hardware = coder.hardware(‘Robot Operating System 2 (ROS 2)’);
cfg.Hardware.BuildAction = ‘Build and load’;
cfg.Hardware.RemoteDeviceAddress = ‘XXX.XXX.XXX.XXX’;
cfg.Hardware.RemoteDeviceUsername = ‘XXXX’;
cfg.Hardware.RemoteDevicePassword = ‘XXXXX’;
cfg.Hardware.DeployTo = ‘Remote Device’;
cfg.Hardware.ROS2Folder = ‘/opt/ros/galactic’;
cfg.Hardware.ROS2Workspace = ‘~/uavrt_ws’;
cfg.HardwareImplementation.ProdHWDeviceType = ‘Intel->x86-64 (Linux 64)’;
cfg.RuntimeChecks = true;%Disable for final deployments.
codegen multirate_tag_sorter_test_simple -args {} -config cfg
The error message
>> multirate_tag_sorter_test_codegen_script
??? Expected a parameter name.
Error in ==> multirate_tag_sorter_test_simple Line: 7 Column: 9
Code generation failed: View Error Report
Error using codegen
Error in multirate_tag_sorter_test_codegen_script (line 22)
codegen multirate_tag_sorter_test_simple -args {} -config cfg I need to pass additional variables to my ROS2 subscriber callback function. I am trying to follow the help file explicity, which states:
"callback can be a single function handle or a cell array. The first element of the cell array needs to be a function handle or a string containing the name of a function. The remaining elements of the cell array can be arbitrary user data that will be passed to the callback function."
Based on this I built the following function to run my ROS2 subscriber node:
function [] = multirate_tag_sorter_test_simple()
node = ros2node("myNode",0);
myMsg = ros2message("builtin_interfaces/Time");
tableA = struct2table(myMsg, ‘AsArray’, true);
%% THE CREATING PROBLEMS —V
mySub = ros2subscriber(node,"/myTopic","builtin_interfaces/Time",{@receivedMessageCallback,tableA});
%
while true
fprintf(‘Waiting for messages to arrive…n’)
pause(5);
end
function receivedMessageCallback(src,msg,inputTable)
fprintf(‘MESSAGE RECEIVED!’);
end
end
but this generates error for code generation (see end of this question). The callback works fine if I don’t try to pass additional arguments (i.e. mySub = ros2subscriber(node,"/myTopic","builtin_interfaces/Time",@receivedMessageCallback). The issue I am having is that when I try to specify the callback as {@receivedMessageCallback,tableA}, I get the error message shown at the bottom of this message.
The error message states that it expects a parameter name. It seems that Coder doesn’t know that {@func,var1} is a callback function declaration. Unfortunately, callback functions are not listed in the nave-value pair list in the help file for ros2subscriber. I even tried setting the property manually after the subscriber intialization,
mySub = ros2subscriber(node,"/myTopic","builtin_interfaces/Time")
mySub.NewMessageFnc = {@receivedMessageCallback,tableA};
but got an error stating that NewMessageFnc is immutable, so it must be specified in the ros2subscriber call. Is this a bug with code generation for these callbacks, or am I doing something wrong? If it is a bug, is there a work around? Thanks.
The code generation script
cfg = coder.config(‘exe’);
cfg.Hardware = coder.hardware(‘Robot Operating System 2 (ROS 2)’);
cfg.Hardware.BuildAction = ‘Build and load’;
cfg.Hardware.RemoteDeviceAddress = ‘XXX.XXX.XXX.XXX’;
cfg.Hardware.RemoteDeviceUsername = ‘XXXX’;
cfg.Hardware.RemoteDevicePassword = ‘XXXXX’;
cfg.Hardware.DeployTo = ‘Remote Device’;
cfg.Hardware.ROS2Folder = ‘/opt/ros/galactic’;
cfg.Hardware.ROS2Workspace = ‘~/uavrt_ws’;
cfg.HardwareImplementation.ProdHWDeviceType = ‘Intel->x86-64 (Linux 64)’;
cfg.RuntimeChecks = true;%Disable for final deployments.
codegen multirate_tag_sorter_test_simple -args {} -config cfg
The error message
>> multirate_tag_sorter_test_codegen_script
??? Expected a parameter name.
Error in ==> multirate_tag_sorter_test_simple Line: 7 Column: 9
Code generation failed: View Error Report
Error using codegen
Error in multirate_tag_sorter_test_codegen_script (line 22)
codegen multirate_tag_sorter_test_simple -args {} -config cfg ros2, ros2subscriber, callback, codegen MATLAB Answers — New Questions
Index exceeds matrix dimensions. Error in gtc21 (line 21) outputBits = mod(sum(shiftedValues(generatorPolynomials)), 2);
Index exceeds matrix dimensions.
Error in gtc21 (line 21)
outputBits = mod(sum(shiftedValues(generatorPolynomials)), 2);Index exceeds matrix dimensions.
Error in gtc21 (line 21)
outputBits = mod(sum(shiftedValues(generatorPolynomials)), 2); Index exceeds matrix dimensions.
Error in gtc21 (line 21)
outputBits = mod(sum(shiftedValues(generatorPolynomials)), 2); index exceeds matrix dimensions. error in gtc21 ( MATLAB Answers — New Questions
how to generate MATLAB code from Simulink model
Hi,
I have a relatively complex simulink model, from which a MATLAB code must be generated. I want to use the generated code in App designer to develop an app and finally compile the app using `Application Compiler`, so that it can be used on every system without having MATLAB installed.
The process can be summed up as the following:
Simulink –> MATLAB code (.m) –> App Designer –> Application compiler (.exe)Hi,
I have a relatively complex simulink model, from which a MATLAB code must be generated. I want to use the generated code in App designer to develop an app and finally compile the app using `Application Compiler`, so that it can be used on every system without having MATLAB installed.
The process can be summed up as the following:
Simulink –> MATLAB code (.m) –> App Designer –> Application compiler (.exe) Hi,
I have a relatively complex simulink model, from which a MATLAB code must be generated. I want to use the generated code in App designer to develop an app and finally compile the app using `Application Compiler`, so that it can be used on every system without having MATLAB installed.
The process can be summed up as the following:
Simulink –> MATLAB code (.m) –> App Designer –> Application compiler (.exe) code generation, simulink, app designer MATLAB Answers — New Questions