Tag Archives: matlab
Cannot run matlab R2023a orE2023b installer on centos 7.9
Package installer does not work (it hangs indefinitely), when trying to run bin/glnxa64/MATLABWindow I get (note this also happens with version 2023a):
user@lm:/u/local/downloads/matlab/R2023b_temp/bin/glnxa64 {1088}$ ./MATLABWindow
[0914/181150.225297:INFO:client_app.cpp(421)] Dealing with user ID
[0914/181150.225395:INFO:client_app.cpp(428)] Process is not running as root
[0914/181150.235757:INFO:client_app.cpp(478)] In ClientApp::OnBeforeChildProcessLaunch
[0914/181150.235800:INFO:client_app.cpp(484)] Not appending enable-binary-transport
[0914/181150.236932:INFO:client_app.cpp(478)] In ClientApp::OnBeforeChildProcessLaunch
[0914/181150.237303:INFO:client_app.cpp(484)] Not appending enable-binary-transport
[0914/181150.355055:INFO:client_app.cpp(421)] Dealing with user ID
[0914/181150.355064:INFO:client_app.cpp(421)] Dealing with user ID
[0914/181150.355129:INFO:client_app.cpp(428)] Process is not running as root
[0914/181150.355132:INFO:client_app.cpp(428)] Process is not running as root
[0914/181150.421408:INFO:client_app.cpp(478)] In ClientApp::OnBeforeChildProcessLaunch
[0914/181150.421448:INFO:client_app.cpp(484)] Not appending enable-binary-transport
./MATLABWindow: symbol lookup error: /u/local/downloads/matlab/R2023b_temp/bin/glnxa64/libstdc++.so.6: undefined symbol: __cxa_thread_atexit_impl
usr@lm:/u/local/downloads/matlab/R2023b_temp/bin/glnxa64 {1089}$ [0100/000000.561825:WARNING:sandbox_linux.cc(376)] InitializeSandbox() called with multiple threads in process gpu-process.Package installer does not work (it hangs indefinitely), when trying to run bin/glnxa64/MATLABWindow I get (note this also happens with version 2023a):
user@lm:/u/local/downloads/matlab/R2023b_temp/bin/glnxa64 {1088}$ ./MATLABWindow
[0914/181150.225297:INFO:client_app.cpp(421)] Dealing with user ID
[0914/181150.225395:INFO:client_app.cpp(428)] Process is not running as root
[0914/181150.235757:INFO:client_app.cpp(478)] In ClientApp::OnBeforeChildProcessLaunch
[0914/181150.235800:INFO:client_app.cpp(484)] Not appending enable-binary-transport
[0914/181150.236932:INFO:client_app.cpp(478)] In ClientApp::OnBeforeChildProcessLaunch
[0914/181150.237303:INFO:client_app.cpp(484)] Not appending enable-binary-transport
[0914/181150.355055:INFO:client_app.cpp(421)] Dealing with user ID
[0914/181150.355064:INFO:client_app.cpp(421)] Dealing with user ID
[0914/181150.355129:INFO:client_app.cpp(428)] Process is not running as root
[0914/181150.355132:INFO:client_app.cpp(428)] Process is not running as root
[0914/181150.421408:INFO:client_app.cpp(478)] In ClientApp::OnBeforeChildProcessLaunch
[0914/181150.421448:INFO:client_app.cpp(484)] Not appending enable-binary-transport
./MATLABWindow: symbol lookup error: /u/local/downloads/matlab/R2023b_temp/bin/glnxa64/libstdc++.so.6: undefined symbol: __cxa_thread_atexit_impl
usr@lm:/u/local/downloads/matlab/R2023b_temp/bin/glnxa64 {1089}$ [0100/000000.561825:WARNING:sandbox_linux.cc(376)] InitializeSandbox() called with multiple threads in process gpu-process. Package installer does not work (it hangs indefinitely), when trying to run bin/glnxa64/MATLABWindow I get (note this also happens with version 2023a):
user@lm:/u/local/downloads/matlab/R2023b_temp/bin/glnxa64 {1088}$ ./MATLABWindow
[0914/181150.225297:INFO:client_app.cpp(421)] Dealing with user ID
[0914/181150.225395:INFO:client_app.cpp(428)] Process is not running as root
[0914/181150.235757:INFO:client_app.cpp(478)] In ClientApp::OnBeforeChildProcessLaunch
[0914/181150.235800:INFO:client_app.cpp(484)] Not appending enable-binary-transport
[0914/181150.236932:INFO:client_app.cpp(478)] In ClientApp::OnBeforeChildProcessLaunch
[0914/181150.237303:INFO:client_app.cpp(484)] Not appending enable-binary-transport
[0914/181150.355055:INFO:client_app.cpp(421)] Dealing with user ID
[0914/181150.355064:INFO:client_app.cpp(421)] Dealing with user ID
[0914/181150.355129:INFO:client_app.cpp(428)] Process is not running as root
[0914/181150.355132:INFO:client_app.cpp(428)] Process is not running as root
[0914/181150.421408:INFO:client_app.cpp(478)] In ClientApp::OnBeforeChildProcessLaunch
[0914/181150.421448:INFO:client_app.cpp(484)] Not appending enable-binary-transport
./MATLABWindow: symbol lookup error: /u/local/downloads/matlab/R2023b_temp/bin/glnxa64/libstdc++.so.6: undefined symbol: __cxa_thread_atexit_impl
usr@lm:/u/local/downloads/matlab/R2023b_temp/bin/glnxa64 {1089}$ [0100/000000.561825:WARNING:sandbox_linux.cc(376)] InitializeSandbox() called with multiple threads in process gpu-process. installation, r2023a, r2023b MATLAB Answers — New Questions
How to optimize a bi-exponential signal fitting?
Hi everybody!
I’m trying to solve a fitting curve problem concerning a double-exponential fit.
I have this data set (Data.txt) that behaves like a bi-exponential function following a resting condition. Therefore, since x<0 the signal is almost steady whereas, for x>0 the signal presents a first exponential phase (lasting about 20 sec) followed by a second exponential phase.
The problem is that the resulting fitting does not model the signal behavior in the correct way. Specifically, the first exp phase is too short and/or too low even though correct StartingPoint and Upper and Lower limits are set.
Lastly, I’ve written two algorithms with and without "Exclude" options. The second one presents a strange pattern at the onset of the second exp function.
I’ll appreciate any suggestions.
This is the code.
[x, y] = readvars(‘prova.txt’);
tRest = abs(min(x)); % Resting phase duration (sec)
cdp = 20; % estimated duration (sec) of CardioDynamicPhase (cdp)
cdpEpoch = 5; % epoch duration (sec) to compute mean value of amplitude of cdp
plot(x,y);
% Fitting StartingPoint
yRest = mean( y(1:tRest-1) ); % y value at resting condition before exp onset
A1start = mean( y(1:tRest+cdp-cdpEpoch):y(tRest+cdp) )-yRest; % mean y value of the last 5sec of the cardiodynamic phase
TD1start = 0; % starting value (sec) of the first exponential phase onset
tau1Start = 8; % starting value (sec) of the first exponential phase time constant
A2start = max(y)-A1start-yRest; % starting value of the second exponential phase amplitude
TD2start = 30; % starting value (sec) of the second exponential phase onset
tau2Start = 30; % starting value (sec) of the second exponential phase time constant
% Fitting from exponential onset
g = fittype( @(A1, TD1, tau1, A2, TD2, tau2, yRest, x) yRest+A1.*(1-exp(-(x-TD1)/tau1))+A2.*(1-exp(-(x-TD2)/tau2)), ‘problem’, ‘yRest’);
f1 = fit( x(tRest:size(x,1)), y(tRest:size(x,1)), g, ‘problem’, yRest, ‘StartPoint’, [A1start, TD1start, tau1Start, A2start, TD2start, tau2Start], ‘lower’ , [ A1start-100, 0, 5, A2start-200, 10, 10], ‘upper’, [ A1start+200, 20, 40, max(y), 60, 40], ‘MaxIter’, 10000);
pg =coeffvalues(f1);
A1 = pg(1);
TD1 = pg(2);
tau1 = pg(3);
A2 = pg(4);
TD2 = pg(5);
tau2 = pg(6);
yFit( 1:(tRest+floor(TD1)) ) = yRest;
yFit( tRest+floor(TD1)+1 : tRest+floor(TD2) ) = yRest + A1.*(1-exp(-( x(tRest+floor(TD1)+1 : tRest+floor(TD2))-TD1 )/tau1));
yFit( tRest+floor(TD2)+1 : size(y,1)) = yFit(tRest+floor(TD2))+ A2.*(1-exp(-( x(tRest+floor(TD2)+1 : size(y,1))-TD2 )/tau2));
% fitting using Exclude option
f2 = fit( x, y, g, ‘problem’, yRest, ‘StartPoint’, [A1start, TD1start, tau1Start, A2start, TD2start, tau2Start], ‘lower’ , [ 390, 0, 5, A2start-200, 10, 10], ‘upper’, [ 400, 20, 40, max(y), 60, 40], ‘Exclude’, x<0); %Same fitting algortihm that exclude negative x values
pg2=coeffvalues(f2);
A1e = pg2(1);
TD1e = pg2(2);
tau1e = pg2(3);
A2e = pg2(4);
TD2e = pg2(5);
tau2e = pg2(6);
yFite( 1:(tRest+floor(TD1e)) ) = yRest;
yFite( tRest+floor(TD1e)+1 : tRest+floor(TD2e) ) = yRest + A1e.*(1-exp(-( x(tRest+floor(TD1e)+1 : tRest+floor(TD2e))-TD1e )/tau1e));
yFite( tRest+floor(TD2e)+1 : size(y,1)) = yFit(tRest+floor(TD2e))+ A2e.*(1-exp(-( x(tRest+floor(TD2e)+1 : size(y,1))-TD2e )/tau2e));
% Plot the fitting curves
hold on
plot (x, yFit, ‘r’);
plot (x, yFite, ‘k’);Hi everybody!
I’m trying to solve a fitting curve problem concerning a double-exponential fit.
I have this data set (Data.txt) that behaves like a bi-exponential function following a resting condition. Therefore, since x<0 the signal is almost steady whereas, for x>0 the signal presents a first exponential phase (lasting about 20 sec) followed by a second exponential phase.
The problem is that the resulting fitting does not model the signal behavior in the correct way. Specifically, the first exp phase is too short and/or too low even though correct StartingPoint and Upper and Lower limits are set.
Lastly, I’ve written two algorithms with and without "Exclude" options. The second one presents a strange pattern at the onset of the second exp function.
I’ll appreciate any suggestions.
This is the code.
[x, y] = readvars(‘prova.txt’);
tRest = abs(min(x)); % Resting phase duration (sec)
cdp = 20; % estimated duration (sec) of CardioDynamicPhase (cdp)
cdpEpoch = 5; % epoch duration (sec) to compute mean value of amplitude of cdp
plot(x,y);
% Fitting StartingPoint
yRest = mean( y(1:tRest-1) ); % y value at resting condition before exp onset
A1start = mean( y(1:tRest+cdp-cdpEpoch):y(tRest+cdp) )-yRest; % mean y value of the last 5sec of the cardiodynamic phase
TD1start = 0; % starting value (sec) of the first exponential phase onset
tau1Start = 8; % starting value (sec) of the first exponential phase time constant
A2start = max(y)-A1start-yRest; % starting value of the second exponential phase amplitude
TD2start = 30; % starting value (sec) of the second exponential phase onset
tau2Start = 30; % starting value (sec) of the second exponential phase time constant
% Fitting from exponential onset
g = fittype( @(A1, TD1, tau1, A2, TD2, tau2, yRest, x) yRest+A1.*(1-exp(-(x-TD1)/tau1))+A2.*(1-exp(-(x-TD2)/tau2)), ‘problem’, ‘yRest’);
f1 = fit( x(tRest:size(x,1)), y(tRest:size(x,1)), g, ‘problem’, yRest, ‘StartPoint’, [A1start, TD1start, tau1Start, A2start, TD2start, tau2Start], ‘lower’ , [ A1start-100, 0, 5, A2start-200, 10, 10], ‘upper’, [ A1start+200, 20, 40, max(y), 60, 40], ‘MaxIter’, 10000);
pg =coeffvalues(f1);
A1 = pg(1);
TD1 = pg(2);
tau1 = pg(3);
A2 = pg(4);
TD2 = pg(5);
tau2 = pg(6);
yFit( 1:(tRest+floor(TD1)) ) = yRest;
yFit( tRest+floor(TD1)+1 : tRest+floor(TD2) ) = yRest + A1.*(1-exp(-( x(tRest+floor(TD1)+1 : tRest+floor(TD2))-TD1 )/tau1));
yFit( tRest+floor(TD2)+1 : size(y,1)) = yFit(tRest+floor(TD2))+ A2.*(1-exp(-( x(tRest+floor(TD2)+1 : size(y,1))-TD2 )/tau2));
% fitting using Exclude option
f2 = fit( x, y, g, ‘problem’, yRest, ‘StartPoint’, [A1start, TD1start, tau1Start, A2start, TD2start, tau2Start], ‘lower’ , [ 390, 0, 5, A2start-200, 10, 10], ‘upper’, [ 400, 20, 40, max(y), 60, 40], ‘Exclude’, x<0); %Same fitting algortihm that exclude negative x values
pg2=coeffvalues(f2);
A1e = pg2(1);
TD1e = pg2(2);
tau1e = pg2(3);
A2e = pg2(4);
TD2e = pg2(5);
tau2e = pg2(6);
yFite( 1:(tRest+floor(TD1e)) ) = yRest;
yFite( tRest+floor(TD1e)+1 : tRest+floor(TD2e) ) = yRest + A1e.*(1-exp(-( x(tRest+floor(TD1e)+1 : tRest+floor(TD2e))-TD1e )/tau1e));
yFite( tRest+floor(TD2e)+1 : size(y,1)) = yFit(tRest+floor(TD2e))+ A2e.*(1-exp(-( x(tRest+floor(TD2e)+1 : size(y,1))-TD2e )/tau2e));
% Plot the fitting curves
hold on
plot (x, yFit, ‘r’);
plot (x, yFite, ‘k’); Hi everybody!
I’m trying to solve a fitting curve problem concerning a double-exponential fit.
I have this data set (Data.txt) that behaves like a bi-exponential function following a resting condition. Therefore, since x<0 the signal is almost steady whereas, for x>0 the signal presents a first exponential phase (lasting about 20 sec) followed by a second exponential phase.
The problem is that the resulting fitting does not model the signal behavior in the correct way. Specifically, the first exp phase is too short and/or too low even though correct StartingPoint and Upper and Lower limits are set.
Lastly, I’ve written two algorithms with and without "Exclude" options. The second one presents a strange pattern at the onset of the second exp function.
I’ll appreciate any suggestions.
This is the code.
[x, y] = readvars(‘prova.txt’);
tRest = abs(min(x)); % Resting phase duration (sec)
cdp = 20; % estimated duration (sec) of CardioDynamicPhase (cdp)
cdpEpoch = 5; % epoch duration (sec) to compute mean value of amplitude of cdp
plot(x,y);
% Fitting StartingPoint
yRest = mean( y(1:tRest-1) ); % y value at resting condition before exp onset
A1start = mean( y(1:tRest+cdp-cdpEpoch):y(tRest+cdp) )-yRest; % mean y value of the last 5sec of the cardiodynamic phase
TD1start = 0; % starting value (sec) of the first exponential phase onset
tau1Start = 8; % starting value (sec) of the first exponential phase time constant
A2start = max(y)-A1start-yRest; % starting value of the second exponential phase amplitude
TD2start = 30; % starting value (sec) of the second exponential phase onset
tau2Start = 30; % starting value (sec) of the second exponential phase time constant
% Fitting from exponential onset
g = fittype( @(A1, TD1, tau1, A2, TD2, tau2, yRest, x) yRest+A1.*(1-exp(-(x-TD1)/tau1))+A2.*(1-exp(-(x-TD2)/tau2)), ‘problem’, ‘yRest’);
f1 = fit( x(tRest:size(x,1)), y(tRest:size(x,1)), g, ‘problem’, yRest, ‘StartPoint’, [A1start, TD1start, tau1Start, A2start, TD2start, tau2Start], ‘lower’ , [ A1start-100, 0, 5, A2start-200, 10, 10], ‘upper’, [ A1start+200, 20, 40, max(y), 60, 40], ‘MaxIter’, 10000);
pg =coeffvalues(f1);
A1 = pg(1);
TD1 = pg(2);
tau1 = pg(3);
A2 = pg(4);
TD2 = pg(5);
tau2 = pg(6);
yFit( 1:(tRest+floor(TD1)) ) = yRest;
yFit( tRest+floor(TD1)+1 : tRest+floor(TD2) ) = yRest + A1.*(1-exp(-( x(tRest+floor(TD1)+1 : tRest+floor(TD2))-TD1 )/tau1));
yFit( tRest+floor(TD2)+1 : size(y,1)) = yFit(tRest+floor(TD2))+ A2.*(1-exp(-( x(tRest+floor(TD2)+1 : size(y,1))-TD2 )/tau2));
% fitting using Exclude option
f2 = fit( x, y, g, ‘problem’, yRest, ‘StartPoint’, [A1start, TD1start, tau1Start, A2start, TD2start, tau2Start], ‘lower’ , [ 390, 0, 5, A2start-200, 10, 10], ‘upper’, [ 400, 20, 40, max(y), 60, 40], ‘Exclude’, x<0); %Same fitting algortihm that exclude negative x values
pg2=coeffvalues(f2);
A1e = pg2(1);
TD1e = pg2(2);
tau1e = pg2(3);
A2e = pg2(4);
TD2e = pg2(5);
tau2e = pg2(6);
yFite( 1:(tRest+floor(TD1e)) ) = yRest;
yFite( tRest+floor(TD1e)+1 : tRest+floor(TD2e) ) = yRest + A1e.*(1-exp(-( x(tRest+floor(TD1e)+1 : tRest+floor(TD2e))-TD1e )/tau1e));
yFite( tRest+floor(TD2e)+1 : size(y,1)) = yFit(tRest+floor(TD2e))+ A2e.*(1-exp(-( x(tRest+floor(TD2e)+1 : size(y,1))-TD2e )/tau2e));
% Plot the fitting curves
hold on
plot (x, yFit, ‘r’);
plot (x, yFite, ‘k’); signal fitting MATLAB Answers — New Questions
changes for MSK to GMSK in MATLAB example
Hi, In this example, what all changes we need to make for recovering a GMSK signal. openExample(‘comm/MSKSignalRecoveryInSimulinkExample’)
Im getting a high BER value. despite changing the GMSK modulator and demodulator, and GMSK tsignal timing recovery block.Hi, In this example, what all changes we need to make for recovering a GMSK signal. openExample(‘comm/MSKSignalRecoveryInSimulinkExample’)
Im getting a high BER value. despite changing the GMSK modulator and demodulator, and GMSK tsignal timing recovery block. Hi, In this example, what all changes we need to make for recovering a GMSK signal. openExample(‘comm/MSKSignalRecoveryInSimulinkExample’)
Im getting a high BER value. despite changing the GMSK modulator and demodulator, and GMSK tsignal timing recovery block. gmsk, msk, signal recovery, ber MATLAB Answers — New Questions
Error in port widths or dimensions.
Error in port widths or dimensions. Output port 1 of ‘last/Subsystem/powergui/EquivalentModel1/Gates/From2’ is a one dimensional vector with 2 elements.
AND
Error in port widths or dimensions. Invalid dimension has been specified for input port 2 of ‘last/Subsystem/powergui/EquivalentModel1/Gates/Mux’.
I am using MATLAB 2010a. problem occurred in the switching circuit of invert.
Anticipating your answers…
<</matlabcentral/answers/uploaded_files/38534/1.png>>
<</matlabcentral/answers/uploaded_files/38535/2.png>>Error in port widths or dimensions. Output port 1 of ‘last/Subsystem/powergui/EquivalentModel1/Gates/From2’ is a one dimensional vector with 2 elements.
AND
Error in port widths or dimensions. Invalid dimension has been specified for input port 2 of ‘last/Subsystem/powergui/EquivalentModel1/Gates/Mux’.
I am using MATLAB 2010a. problem occurred in the switching circuit of invert.
Anticipating your answers…
<</matlabcentral/answers/uploaded_files/38534/1.png>>
<</matlabcentral/answers/uploaded_files/38535/2.png>> Error in port widths or dimensions. Output port 1 of ‘last/Subsystem/powergui/EquivalentModel1/Gates/From2’ is a one dimensional vector with 2 elements.
AND
Error in port widths or dimensions. Invalid dimension has been specified for input port 2 of ‘last/Subsystem/powergui/EquivalentModel1/Gates/Mux’.
I am using MATLAB 2010a. problem occurred in the switching circuit of invert.
Anticipating your answers…
<</matlabcentral/answers/uploaded_files/38534/1.png>>
<</matlabcentral/answers/uploaded_files/38535/2.png>> MATLAB Answers — New Questions
Give me a matlab code for plotting graph and solving the BVP. using Keller Box Method f^iv+R(f’f”-ff”’)=0 with boundary conditions f'(1)=-Φf”(0) ,f”(0)=0 ,f(0)=0,f(1)=1
…… … keller box method, matlab code MATLAB Answers — New Questions
how to fix an error:” error in port widths or dimensions.”
Hello everyone,
I made a state space representation with disturbances using blocks in simulink, then I connected this state space to model predictive control, and when I run the system it gives an error as shown below: the red spot in the figure is where the error is,
and my state space model is as follow:
so A, B, C and D and Bd should be correct as I made them, right?Hello everyone,
I made a state space representation with disturbances using blocks in simulink, then I connected this state space to model predictive control, and when I run the system it gives an error as shown below: the red spot in the figure is where the error is,
and my state space model is as follow:
so A, B, C and D and Bd should be correct as I made them, right? Hello everyone,
I made a state space representation with disturbances using blocks in simulink, then I connected this state space to model predictive control, and when I run the system it gives an error as shown below: the red spot in the figure is where the error is,
and my state space model is as follow:
so A, B, C and D and Bd should be correct as I made them, right? matlab, simulink, model predictive controller, state space representation MATLAB Answers — New Questions
iam unable to see output for open ciruit voltage of pv array. it is showing as ”nan”
Post Content Post Content unable to get output MATLAB Answers — New Questions
reckon function query
Hi i am looking to try calculate the latitude and longitude of a point on the ground with respect to an aircraft which has a lat lon but obviously at a specific height, a azmiuth and elevation look angle and also range to the point on ground ( all known ) .
[latout, lonout] = reckon(lat, lon, rng, az)
e.g from help section
dist = nm2deg(600) % convert nm distance to degrees
dist =
9.9933
pt1 = reckon(51.5,0,dist,315) % northwest is 315 degrees
pt1 =
57.8999 -13.3507
The reckon function seems to do near enough exactly what i want but does not take in account elevation angle ( i.e assumes both points are on the ground)
Is there any function similar that i can achieve being able to add in an elevation angle to the calculation, or change the reckon function in anyway?
Any help much appreciatedHi i am looking to try calculate the latitude and longitude of a point on the ground with respect to an aircraft which has a lat lon but obviously at a specific height, a azmiuth and elevation look angle and also range to the point on ground ( all known ) .
[latout, lonout] = reckon(lat, lon, rng, az)
e.g from help section
dist = nm2deg(600) % convert nm distance to degrees
dist =
9.9933
pt1 = reckon(51.5,0,dist,315) % northwest is 315 degrees
pt1 =
57.8999 -13.3507
The reckon function seems to do near enough exactly what i want but does not take in account elevation angle ( i.e assumes both points are on the ground)
Is there any function similar that i can achieve being able to add in an elevation angle to the calculation, or change the reckon function in anyway?
Any help much appreciated Hi i am looking to try calculate the latitude and longitude of a point on the ground with respect to an aircraft which has a lat lon but obviously at a specific height, a azmiuth and elevation look angle and also range to the point on ground ( all known ) .
[latout, lonout] = reckon(lat, lon, rng, az)
e.g from help section
dist = nm2deg(600) % convert nm distance to degrees
dist =
9.9933
pt1 = reckon(51.5,0,dist,315) % northwest is 315 degrees
pt1 =
57.8999 -13.3507
The reckon function seems to do near enough exactly what i want but does not take in account elevation angle ( i.e assumes both points are on the ground)
Is there any function similar that i can achieve being able to add in an elevation angle to the calculation, or change the reckon function in anyway?
Any help much appreciated reckon MATLAB Answers — New Questions
How do I fix Simulink.DataType object not in scope while using c caller?
I am using c caller and function used in that is pid controller. While simulating that its showing error like "Unable to resolve ‘PID_vars’ to a valid type for input port 0 of ‘pidexmpl/C Caller’.
Caused by:
Simulink.DataType object ‘PID_vars’ is not in scope from ‘pidexmpl/C Caller’". Can someone tell me how to resolve this error?I am using c caller and function used in that is pid controller. While simulating that its showing error like "Unable to resolve ‘PID_vars’ to a valid type for input port 0 of ‘pidexmpl/C Caller’.
Caused by:
Simulink.DataType object ‘PID_vars’ is not in scope from ‘pidexmpl/C Caller’". Can someone tell me how to resolve this error? I am using c caller and function used in that is pid controller. While simulating that its showing error like "Unable to resolve ‘PID_vars’ to a valid type for input port 0 of ‘pidexmpl/C Caller’.
Caused by:
Simulink.DataType object ‘PID_vars’ is not in scope from ‘pidexmpl/C Caller’". Can someone tell me how to resolve this error? #c caller, #simulink.datatype MATLAB Answers — New Questions
Save entire Simulink model by MATLAB command
Hi, Simulink supporters team
I want to print my Entire model as pdf by MATLAB script instead of By Print Option in Simulnik Toolstrip. I have tried 2 ways:
1.Using print( ) function but it only print first page of my model
2. Using exportgraphics( ) but it does not support for Simulink model.
So, is there any way to solve this problem?Hi, Simulink supporters team
I want to print my Entire model as pdf by MATLAB script instead of By Print Option in Simulnik Toolstrip. I have tried 2 ways:
1.Using print( ) function but it only print first page of my model
2. Using exportgraphics( ) but it does not support for Simulink model.
So, is there any way to solve this problem? Hi, Simulink supporters team
I want to print my Entire model as pdf by MATLAB script instead of By Print Option in Simulnik Toolstrip. I have tried 2 ways:
1.Using print( ) function but it only print first page of my model
2. Using exportgraphics( ) but it does not support for Simulink model.
So, is there any way to solve this problem? print, model, matlab, command MATLAB Answers — New Questions
How to interface simulink and display with GC9A01A driver from waveshare?
I recently bought a waveshare 1.28 inch round display. I use a raspberry pi model 4 b as my micro controller. I have been able to diplsy texts and images using C and python. But I would like to do the same using simulink. I wanna be able to deply the code and have the display show some text or image based on certain button being pressed. It uses SPI communication. Can someone help me with how to do this?I recently bought a waveshare 1.28 inch round display. I use a raspberry pi model 4 b as my micro controller. I have been able to diplsy texts and images using C and python. But I would like to do the same using simulink. I wanna be able to deply the code and have the display show some text or image based on certain button being pressed. It uses SPI communication. Can someone help me with how to do this? I recently bought a waveshare 1.28 inch round display. I use a raspberry pi model 4 b as my micro controller. I have been able to diplsy texts and images using C and python. But I would like to do the same using simulink. I wanna be able to deply the code and have the display show some text or image based on certain button being pressed. It uses SPI communication. Can someone help me with how to do this? spi, gc9a01a, raspberry pi, simulink MATLAB Answers — New Questions
ADSR Audio Envelope: How to get it?
How can I get the ADSR sample points of a audio file…Like:
"Fake" example:
[Amp, SR] = audioread(audio.file);
[a d s r] = get_ADSR(Amp);
% Results: The sample position of the Amp vector:
a = 85 % End of Attack -> Attack start = Amp(0)
d = 300 % End of Decay
s = 2456 % End of Sustain
r = 50000 % End of ReleaseHow can I get the ADSR sample points of a audio file…Like:
"Fake" example:
[Amp, SR] = audioread(audio.file);
[a d s r] = get_ADSR(Amp);
% Results: The sample position of the Amp vector:
a = 85 % End of Attack -> Attack start = Amp(0)
d = 300 % End of Decay
s = 2456 % End of Sustain
r = 50000 % End of Release How can I get the ADSR sample points of a audio file…Like:
"Fake" example:
[Amp, SR] = audioread(audio.file);
[a d s r] = get_ADSR(Amp);
% Results: The sample position of the Amp vector:
a = 85 % End of Attack -> Attack start = Amp(0)
d = 300 % End of Decay
s = 2456 % End of Sustain
r = 50000 % End of Release envelope, adsr, audio, wave MATLAB Answers — New Questions
App UIFigure Visibility Bug
I have Multi-Windows Application written with GUIDE. Currently I Tried to Migrate to App Designer.
My Problem: I Design An App, That Its Visibility Turned Off In App Startup Callback.
In Some Place, I Change The Position of That Windows (In Other Program Module), But Before User Decide to Click A Menu to show That App.
Its Very Odd That, The Windows Appears As Soon As Position Changed. I Tried to Turn It Visiblity Back to Off Again After Position Change Line. But It Didnt Work. Also Functions Like drawnow not useful (At First I Thought It is An Incomplete rendering problem).
This Is Secondary Windows That Should Be Invisible (app2):
function startupFcn(app)
app.UIFigure.Visible= "off"
end
In Master App, I Define ap2 Public Variable:
function startupFcn(app)
app.ap2= app2
end
And This Is Position Change In Some Callback That Tend To Show app2:
function ChangePositionButtonPushed(app, event)
app.ap2.UIFigure.Position= [100, 100, 1000, 700];
app.ap2.UIFigure.Visible
end
As you see, The 2nd Line Echo "off" Value for ap2.UIFigure, While It is shown.I have Multi-Windows Application written with GUIDE. Currently I Tried to Migrate to App Designer.
My Problem: I Design An App, That Its Visibility Turned Off In App Startup Callback.
In Some Place, I Change The Position of That Windows (In Other Program Module), But Before User Decide to Click A Menu to show That App.
Its Very Odd That, The Windows Appears As Soon As Position Changed. I Tried to Turn It Visiblity Back to Off Again After Position Change Line. But It Didnt Work. Also Functions Like drawnow not useful (At First I Thought It is An Incomplete rendering problem).
This Is Secondary Windows That Should Be Invisible (app2):
function startupFcn(app)
app.UIFigure.Visible= "off"
end
In Master App, I Define ap2 Public Variable:
function startupFcn(app)
app.ap2= app2
end
And This Is Position Change In Some Callback That Tend To Show app2:
function ChangePositionButtonPushed(app, event)
app.ap2.UIFigure.Position= [100, 100, 1000, 700];
app.ap2.UIFigure.Visible
end
As you see, The 2nd Line Echo "off" Value for ap2.UIFigure, While It is shown. I have Multi-Windows Application written with GUIDE. Currently I Tried to Migrate to App Designer.
My Problem: I Design An App, That Its Visibility Turned Off In App Startup Callback.
In Some Place, I Change The Position of That Windows (In Other Program Module), But Before User Decide to Click A Menu to show That App.
Its Very Odd That, The Windows Appears As Soon As Position Changed. I Tried to Turn It Visiblity Back to Off Again After Position Change Line. But It Didnt Work. Also Functions Like drawnow not useful (At First I Thought It is An Incomplete rendering problem).
This Is Secondary Windows That Should Be Invisible (app2):
function startupFcn(app)
app.UIFigure.Visible= "off"
end
In Master App, I Define ap2 Public Variable:
function startupFcn(app)
app.ap2= app2
end
And This Is Position Change In Some Callback That Tend To Show app2:
function ChangePositionButtonPushed(app, event)
app.ap2.UIFigure.Position= [100, 100, 1000, 700];
app.ap2.UIFigure.Visible
end
As you see, The 2nd Line Echo "off" Value for ap2.UIFigure, While It is shown. appdesigner, uifigure, visible, bug MATLAB Answers — New Questions
Accelerometer reading of pixhawk 6X using MATLAB 2024a
I’m now trying to setup the pixhawk 6X using UAV Toolbox Support Package for PX4 Autopilots (ver. 24.12).
I successfully finished the hardware setup.
Next, I created a simple simulink file as below.
I connected the hardware and tried to see the measurement values, but I could not find the values.
(The displayed values are zero.)
Please tell me how to solve this problem.I’m now trying to setup the pixhawk 6X using UAV Toolbox Support Package for PX4 Autopilots (ver. 24.12).
I successfully finished the hardware setup.
Next, I created a simple simulink file as below.
I connected the hardware and tried to see the measurement values, but I could not find the values.
(The displayed values are zero.)
Please tell me how to solve this problem. I’m now trying to setup the pixhawk 6X using UAV Toolbox Support Package for PX4 Autopilots (ver. 24.12).
I successfully finished the hardware setup.
Next, I created a simple simulink file as below.
I connected the hardware and tried to see the measurement values, but I could not find the values.
(The displayed values are zero.)
Please tell me how to solve this problem. pixhawk 6x, matlab, simulink, sensor, uav toolbox support package MATLAB Answers — New Questions
nxn matrix as an input argument in function
function x = matrix(b, L, U)
A= L * U
x= inv(A)*b
end
I am trying to write a function that solves for an matrix, a known vector and an unknown vector. How can I make the above work? In what form am I to input b, L and U into the function arguments?
For
b = $ begin{pmatrix}a\ b \ c end{pmatrix} $.
L =$ begin{pmatrix} d & e & f\ g & h & i \ j & k & lend{pmatrix} $
U=$ begin{pmatrix} m & n & o\ p & q & r \ s & t & uend{pmatrix} $
would my input be like this: matrix([a][b][c], [d,e,f][g,h,i][j,k,l], [m,n,o][p,q,r][s,t,u]) ??function x = matrix(b, L, U)
A= L * U
x= inv(A)*b
end
I am trying to write a function that solves for an matrix, a known vector and an unknown vector. How can I make the above work? In what form am I to input b, L and U into the function arguments?
For
b = $ begin{pmatrix}a\ b \ c end{pmatrix} $.
L =$ begin{pmatrix} d & e & f\ g & h & i \ j & k & lend{pmatrix} $
U=$ begin{pmatrix} m & n & o\ p & q & r \ s & t & uend{pmatrix} $
would my input be like this: matrix([a][b][c], [d,e,f][g,h,i][j,k,l], [m,n,o][p,q,r][s,t,u]) ?? function x = matrix(b, L, U)
A= L * U
x= inv(A)*b
end
I am trying to write a function that solves for an matrix, a known vector and an unknown vector. How can I make the above work? In what form am I to input b, L and U into the function arguments?
For
b = $ begin{pmatrix}a\ b \ c end{pmatrix} $.
L =$ begin{pmatrix} d & e & f\ g & h & i \ j & k & lend{pmatrix} $
U=$ begin{pmatrix} m & n & o\ p & q & r \ s & t & uend{pmatrix} $
would my input be like this: matrix([a][b][c], [d,e,f][g,h,i][j,k,l], [m,n,o][p,q,r][s,t,u]) ?? matrix MATLAB Answers — New Questions
doubt in the backpropagation algorithm
Hi
I’m studying neural networks and i’m doing a NN with 2 hidden layers and one neuron in the output layer
While I was studying and coding my NN, I faced one doubt.
In the backward step, the math behind this is clear:
to the output layer we have:
, where ⊙ is the hadamard product.
and to hidden layers, we have:
my problem is that, when I code this formulas, I need to change the second equation when I will calculate the the gradient of the first hidden layer (the hidden layer next to the input layer) to match the dimensions of the matrix as follow below:
% Backpropagation
delta_saida = erro_estim.*selecionar_funcao(saida_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’True’);
delta_h2 = (w_out’*delta_saida).*selecionar_funcao(h2_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’True’);
delta_h1 = (w2*delta_h2′)’.*selecionar_funcao(h1_in_estim,ativ_h1,sig_a,tanh_a,tanh_b,’True’);
%update weights and biases
w_out = w_out + learning_rate*delta_saida*h2_out_estim’;
b_out = b_out + learning_rate*delta_saida;
w2 = w2 + learning_rate*(delta_h2’*h1_out_estim)’;
b2 = b2 + learning_rate*sum(delta_h2);
w1 = w1 + learning_rate*delta_h1’*enter_estim;
b1 = b1 + learning_rate*sum(delta_h2);
% I wrote this code partially in portuguese so let me explain a litlle.
%’delta_saida’ is the gradient of the output layer
%delta_h2 is the gradient of the second hidden layer
%delta_h1 is the gradient of the first hidden layer
%w_out,w2 and w1 are the weights of output, second hidden layer and first hidden layer, respectively.
%b_out,b2 and b1 are the biases of output, second hidden layer and first hidden layer, respectively.
% the function selecionar_funcao() is just to calculate the derivative accordingly with the activation function of the layer
%As you can see, I need to change delta_h1 to match the matrix dimensions
It is right to change the formula like i’m doing in my code ? I’m asking it because in my mind, the way that we calculate the gradient of all hidden layers must be the same, but in my case it isn’t true. I will share part of my code here to help anyone to see if i’m doing some mistake
%weights and biases initialization
w1 = randn(num_entradas,n_h1)*sqrt(2/num_entradas);
w2 = randn(n_h1,n_h2) *sqrt(2/n_h1);
w_out = randn(n_h2,n_out) *sqrt(2/n_h2);
b1 = randn(1, n_h1) * sqrt(2/num_entradas);
b2 = randn(1, n_h2) * sqrt(2/n_h1);
b_out = randn(1,n_out) * sqrt(2/n_h2);
%backpropagation
for epoch =1:max_epocas
soma_valid = 0;
soma_estim = 0;
%embaralhar os dados
conj_estim = embaralhar(conj_estim);
% conj_valid = embaralhar(conj_valid);
%Validating
for j=1:size(conj_valid,1)
enter_valid = conj_valid(j,2:end);
h1_in_valid = [enter_valid,1]*[w1;b1];
h1_out_valid = selecionar_funcao(h1_in_valid,ativ_h1,sig_a,tanh_a,tanh_b,’False’);
h2_in_valid = [h1_out_valid,1]*[w2;b2];
h2_out_valid = selecionar_funcao(h2_in_valid,ativ_h2,sig_a,tanh_a,tanh_b,’False’);
saida_in_valid = [h2_out_valid,1]*[w_out;b_out];
saida_out_valid = selecionar_funcao(saida_in_valid,ativ_out,sig_a,tanh_a,tanh_b,’False’);
erro_valid = conj_valid(j,1) – saida_out_valid;
soma_valid = soma_valid + (erro_valid^2);
end
erro_atual_valid = (soma_valid/(2*size(conj_valid,1)));
erros_epoca_valid = [erros_epoca_valid;erro_atual_valid];
%trainning
for i =1:size(conj_estim,1)
enter_estim = conj_estim(i,2:end);
h1_in_estim = [enter_estim,1]*[w1;b1];
h1_out_estim = selecionar_funcao(h1_in_estim,ativ_h1,sig_a,tanh_a,tanh_b,’False’);
h2_in_estim = [h1_out_estim,1]*[w2;b2];
h2_out_estim = selecionar_funcao(h2_in_estim,ativ_h2,sig_a,tanh_a,tanh_b,’False’);
saida_in_estim = [h2_out_estim,1]*[w_out;b_out];
saida_out_estim = selecionar_funcao(saida_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’False’);
erro_estim = conj_estim(i,1) – saida_out_estim;
soma_estim = soma_estim + (erro_estim^2);
% Backpropagation
delta_saida = erro_estim.*selecionar_funcao(saida_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’True’);
delta_h2 = (w_out’*delta_saida).*selecionar_funcao(h2_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’True’);
delta_h1 = (w2*delta_h2′)’.*selecionar_funcao(h1_in_estim,ativ_h1,sig_a,tanh_a,tanh_b,’True’);
%atualizar pesos e biases
w_out = w_out + learning_rate*delta_saida*h2_out_estim’;
b_out = b_out + learning_rate*delta_saida;
w2 = w2 + learning_rate*(delta_h2’*h1_out_estim)’;
b2 = b2 + learning_rate*sum(delta_h2);
w1 = w1 + learning_rate*delta_h1’*enter_estim;
b1 = b1 + learning_rate*sum(delta_h2);
end
erro_atual_estim = (soma_estim/(2*size(conj_estim,1)));
erros_epoca_estim = [erros_epoca_estim;erro_atual_estim];
if erros_epoca_estim(epoch) <limiar
break
else
end
endHi
I’m studying neural networks and i’m doing a NN with 2 hidden layers and one neuron in the output layer
While I was studying and coding my NN, I faced one doubt.
In the backward step, the math behind this is clear:
to the output layer we have:
, where ⊙ is the hadamard product.
and to hidden layers, we have:
my problem is that, when I code this formulas, I need to change the second equation when I will calculate the the gradient of the first hidden layer (the hidden layer next to the input layer) to match the dimensions of the matrix as follow below:
% Backpropagation
delta_saida = erro_estim.*selecionar_funcao(saida_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’True’);
delta_h2 = (w_out’*delta_saida).*selecionar_funcao(h2_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’True’);
delta_h1 = (w2*delta_h2′)’.*selecionar_funcao(h1_in_estim,ativ_h1,sig_a,tanh_a,tanh_b,’True’);
%update weights and biases
w_out = w_out + learning_rate*delta_saida*h2_out_estim’;
b_out = b_out + learning_rate*delta_saida;
w2 = w2 + learning_rate*(delta_h2’*h1_out_estim)’;
b2 = b2 + learning_rate*sum(delta_h2);
w1 = w1 + learning_rate*delta_h1’*enter_estim;
b1 = b1 + learning_rate*sum(delta_h2);
% I wrote this code partially in portuguese so let me explain a litlle.
%’delta_saida’ is the gradient of the output layer
%delta_h2 is the gradient of the second hidden layer
%delta_h1 is the gradient of the first hidden layer
%w_out,w2 and w1 are the weights of output, second hidden layer and first hidden layer, respectively.
%b_out,b2 and b1 are the biases of output, second hidden layer and first hidden layer, respectively.
% the function selecionar_funcao() is just to calculate the derivative accordingly with the activation function of the layer
%As you can see, I need to change delta_h1 to match the matrix dimensions
It is right to change the formula like i’m doing in my code ? I’m asking it because in my mind, the way that we calculate the gradient of all hidden layers must be the same, but in my case it isn’t true. I will share part of my code here to help anyone to see if i’m doing some mistake
%weights and biases initialization
w1 = randn(num_entradas,n_h1)*sqrt(2/num_entradas);
w2 = randn(n_h1,n_h2) *sqrt(2/n_h1);
w_out = randn(n_h2,n_out) *sqrt(2/n_h2);
b1 = randn(1, n_h1) * sqrt(2/num_entradas);
b2 = randn(1, n_h2) * sqrt(2/n_h1);
b_out = randn(1,n_out) * sqrt(2/n_h2);
%backpropagation
for epoch =1:max_epocas
soma_valid = 0;
soma_estim = 0;
%embaralhar os dados
conj_estim = embaralhar(conj_estim);
% conj_valid = embaralhar(conj_valid);
%Validating
for j=1:size(conj_valid,1)
enter_valid = conj_valid(j,2:end);
h1_in_valid = [enter_valid,1]*[w1;b1];
h1_out_valid = selecionar_funcao(h1_in_valid,ativ_h1,sig_a,tanh_a,tanh_b,’False’);
h2_in_valid = [h1_out_valid,1]*[w2;b2];
h2_out_valid = selecionar_funcao(h2_in_valid,ativ_h2,sig_a,tanh_a,tanh_b,’False’);
saida_in_valid = [h2_out_valid,1]*[w_out;b_out];
saida_out_valid = selecionar_funcao(saida_in_valid,ativ_out,sig_a,tanh_a,tanh_b,’False’);
erro_valid = conj_valid(j,1) – saida_out_valid;
soma_valid = soma_valid + (erro_valid^2);
end
erro_atual_valid = (soma_valid/(2*size(conj_valid,1)));
erros_epoca_valid = [erros_epoca_valid;erro_atual_valid];
%trainning
for i =1:size(conj_estim,1)
enter_estim = conj_estim(i,2:end);
h1_in_estim = [enter_estim,1]*[w1;b1];
h1_out_estim = selecionar_funcao(h1_in_estim,ativ_h1,sig_a,tanh_a,tanh_b,’False’);
h2_in_estim = [h1_out_estim,1]*[w2;b2];
h2_out_estim = selecionar_funcao(h2_in_estim,ativ_h2,sig_a,tanh_a,tanh_b,’False’);
saida_in_estim = [h2_out_estim,1]*[w_out;b_out];
saida_out_estim = selecionar_funcao(saida_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’False’);
erro_estim = conj_estim(i,1) – saida_out_estim;
soma_estim = soma_estim + (erro_estim^2);
% Backpropagation
delta_saida = erro_estim.*selecionar_funcao(saida_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’True’);
delta_h2 = (w_out’*delta_saida).*selecionar_funcao(h2_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’True’);
delta_h1 = (w2*delta_h2′)’.*selecionar_funcao(h1_in_estim,ativ_h1,sig_a,tanh_a,tanh_b,’True’);
%atualizar pesos e biases
w_out = w_out + learning_rate*delta_saida*h2_out_estim’;
b_out = b_out + learning_rate*delta_saida;
w2 = w2 + learning_rate*(delta_h2’*h1_out_estim)’;
b2 = b2 + learning_rate*sum(delta_h2);
w1 = w1 + learning_rate*delta_h1’*enter_estim;
b1 = b1 + learning_rate*sum(delta_h2);
end
erro_atual_estim = (soma_estim/(2*size(conj_estim,1)));
erros_epoca_estim = [erros_epoca_estim;erro_atual_estim];
if erros_epoca_estim(epoch) <limiar
break
else
end
end Hi
I’m studying neural networks and i’m doing a NN with 2 hidden layers and one neuron in the output layer
While I was studying and coding my NN, I faced one doubt.
In the backward step, the math behind this is clear:
to the output layer we have:
, where ⊙ is the hadamard product.
and to hidden layers, we have:
my problem is that, when I code this formulas, I need to change the second equation when I will calculate the the gradient of the first hidden layer (the hidden layer next to the input layer) to match the dimensions of the matrix as follow below:
% Backpropagation
delta_saida = erro_estim.*selecionar_funcao(saida_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’True’);
delta_h2 = (w_out’*delta_saida).*selecionar_funcao(h2_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’True’);
delta_h1 = (w2*delta_h2′)’.*selecionar_funcao(h1_in_estim,ativ_h1,sig_a,tanh_a,tanh_b,’True’);
%update weights and biases
w_out = w_out + learning_rate*delta_saida*h2_out_estim’;
b_out = b_out + learning_rate*delta_saida;
w2 = w2 + learning_rate*(delta_h2’*h1_out_estim)’;
b2 = b2 + learning_rate*sum(delta_h2);
w1 = w1 + learning_rate*delta_h1’*enter_estim;
b1 = b1 + learning_rate*sum(delta_h2);
% I wrote this code partially in portuguese so let me explain a litlle.
%’delta_saida’ is the gradient of the output layer
%delta_h2 is the gradient of the second hidden layer
%delta_h1 is the gradient of the first hidden layer
%w_out,w2 and w1 are the weights of output, second hidden layer and first hidden layer, respectively.
%b_out,b2 and b1 are the biases of output, second hidden layer and first hidden layer, respectively.
% the function selecionar_funcao() is just to calculate the derivative accordingly with the activation function of the layer
%As you can see, I need to change delta_h1 to match the matrix dimensions
It is right to change the formula like i’m doing in my code ? I’m asking it because in my mind, the way that we calculate the gradient of all hidden layers must be the same, but in my case it isn’t true. I will share part of my code here to help anyone to see if i’m doing some mistake
%weights and biases initialization
w1 = randn(num_entradas,n_h1)*sqrt(2/num_entradas);
w2 = randn(n_h1,n_h2) *sqrt(2/n_h1);
w_out = randn(n_h2,n_out) *sqrt(2/n_h2);
b1 = randn(1, n_h1) * sqrt(2/num_entradas);
b2 = randn(1, n_h2) * sqrt(2/n_h1);
b_out = randn(1,n_out) * sqrt(2/n_h2);
%backpropagation
for epoch =1:max_epocas
soma_valid = 0;
soma_estim = 0;
%embaralhar os dados
conj_estim = embaralhar(conj_estim);
% conj_valid = embaralhar(conj_valid);
%Validating
for j=1:size(conj_valid,1)
enter_valid = conj_valid(j,2:end);
h1_in_valid = [enter_valid,1]*[w1;b1];
h1_out_valid = selecionar_funcao(h1_in_valid,ativ_h1,sig_a,tanh_a,tanh_b,’False’);
h2_in_valid = [h1_out_valid,1]*[w2;b2];
h2_out_valid = selecionar_funcao(h2_in_valid,ativ_h2,sig_a,tanh_a,tanh_b,’False’);
saida_in_valid = [h2_out_valid,1]*[w_out;b_out];
saida_out_valid = selecionar_funcao(saida_in_valid,ativ_out,sig_a,tanh_a,tanh_b,’False’);
erro_valid = conj_valid(j,1) – saida_out_valid;
soma_valid = soma_valid + (erro_valid^2);
end
erro_atual_valid = (soma_valid/(2*size(conj_valid,1)));
erros_epoca_valid = [erros_epoca_valid;erro_atual_valid];
%trainning
for i =1:size(conj_estim,1)
enter_estim = conj_estim(i,2:end);
h1_in_estim = [enter_estim,1]*[w1;b1];
h1_out_estim = selecionar_funcao(h1_in_estim,ativ_h1,sig_a,tanh_a,tanh_b,’False’);
h2_in_estim = [h1_out_estim,1]*[w2;b2];
h2_out_estim = selecionar_funcao(h2_in_estim,ativ_h2,sig_a,tanh_a,tanh_b,’False’);
saida_in_estim = [h2_out_estim,1]*[w_out;b_out];
saida_out_estim = selecionar_funcao(saida_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’False’);
erro_estim = conj_estim(i,1) – saida_out_estim;
soma_estim = soma_estim + (erro_estim^2);
% Backpropagation
delta_saida = erro_estim.*selecionar_funcao(saida_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’True’);
delta_h2 = (w_out’*delta_saida).*selecionar_funcao(h2_in_estim,ativ_out,sig_a,tanh_a,tanh_b,’True’);
delta_h1 = (w2*delta_h2′)’.*selecionar_funcao(h1_in_estim,ativ_h1,sig_a,tanh_a,tanh_b,’True’);
%atualizar pesos e biases
w_out = w_out + learning_rate*delta_saida*h2_out_estim’;
b_out = b_out + learning_rate*delta_saida;
w2 = w2 + learning_rate*(delta_h2’*h1_out_estim)’;
b2 = b2 + learning_rate*sum(delta_h2);
w1 = w1 + learning_rate*delta_h1’*enter_estim;
b1 = b1 + learning_rate*sum(delta_h2);
end
erro_atual_estim = (soma_estim/(2*size(conj_estim,1)));
erros_epoca_estim = [erros_epoca_estim;erro_atual_estim];
if erros_epoca_estim(epoch) <limiar
break
else
end
end machine learning, backpropagation MATLAB Answers — New Questions
UDP Communication slowing Simulink Model
Gday all,
For context, I am building a simulink model that will communicate with the simulator X-plane through UDP to control an aircraft. The Simulink model inputs a UDP connection and a live video feed. Using an object detection system to identify key features, a command direction will begiven, and outputted to X-plane through UDP communication.
My issue is that the UDP communication input significantly decreases the performance of the model. I have tried every UDP commenction block avaialble in Simulink. I have tested the simulation with other blocks, and I’m confident that the UDP communication input block (either of them) are the root of the issue. I havent had this issue with other models (such as image segmentation model). Nor does the UDP output show performance issues.
Is there a way to fix the performance issues seen in the model? Is there some UDP secret I dont know about? Workarounds? Would the UDP comminication block be interfereing with any other block (deep learning, PID…)?
Any quidence or tips would be appreciatedGday all,
For context, I am building a simulink model that will communicate with the simulator X-plane through UDP to control an aircraft. The Simulink model inputs a UDP connection and a live video feed. Using an object detection system to identify key features, a command direction will begiven, and outputted to X-plane through UDP communication.
My issue is that the UDP communication input significantly decreases the performance of the model. I have tried every UDP commenction block avaialble in Simulink. I have tested the simulation with other blocks, and I’m confident that the UDP communication input block (either of them) are the root of the issue. I havent had this issue with other models (such as image segmentation model). Nor does the UDP output show performance issues.
Is there a way to fix the performance issues seen in the model? Is there some UDP secret I dont know about? Workarounds? Would the UDP comminication block be interfereing with any other block (deep learning, PID…)?
Any quidence or tips would be appreciated Gday all,
For context, I am building a simulink model that will communicate with the simulator X-plane through UDP to control an aircraft. The Simulink model inputs a UDP connection and a live video feed. Using an object detection system to identify key features, a command direction will begiven, and outputted to X-plane through UDP communication.
My issue is that the UDP communication input significantly decreases the performance of the model. I have tried every UDP commenction block avaialble in Simulink. I have tested the simulation with other blocks, and I’m confident that the UDP communication input block (either of them) are the root of the issue. I havent had this issue with other models (such as image segmentation model). Nor does the UDP output show performance issues.
Is there a way to fix the performance issues seen in the model? Is there some UDP secret I dont know about? Workarounds? Would the UDP comminication block be interfereing with any other block (deep learning, PID…)?
Any quidence or tips would be appreciated simulink, deep learning MATLAB Answers — New Questions
Having Matlab import data from SharePoint
I have a line in my code where data is imported, and I wantto add a directory that can import the data from SharePoint so that anyone who is in the sharepoint can use the same code without having to change the directory. I can’t seem to figur eout how to do this without adding a shortcut, becaus enot everyone would have the same shortcut. If anyone could help with how I can set up the import so that anyone can use the code that would be great! Thanks!I have a line in my code where data is imported, and I wantto add a directory that can import the data from SharePoint so that anyone who is in the sharepoint can use the same code without having to change the directory. I can’t seem to figur eout how to do this without adding a shortcut, becaus enot everyone would have the same shortcut. If anyone could help with how I can set up the import so that anyone can use the code that would be great! Thanks! I have a line in my code where data is imported, and I wantto add a directory that can import the data from SharePoint so that anyone who is in the sharepoint can use the same code without having to change the directory. I can’t seem to figur eout how to do this without adding a shortcut, becaus enot everyone would have the same shortcut. If anyone could help with how I can set up the import so that anyone can use the code that would be great! Thanks! data import, sharepoint, import MATLAB Answers — New Questions
How to return matrix in Matlab using codegen with no c++ memory allocation?
I do not want any dynamic memory allocation to be done in the C++ codegen. Here is the relevant Matlab code:
% Calculate cross-correlation matrix from a set of vectors (whose length
% can vary from one call to another). All 4 channels will have the length.
function [R] = xcorr_matrix(ch0,ch1,ch2,ch3,channelCount)
% channelCount is 2 or 4
% R is either 2×2 or 4×4 complex double matrix.
% ch0 … ch3 are complex single vectors.
N = int32(size(ch0,1));
% Convert ch0, …, ch3 to complex double
x_in = coder.nullcopy(complex(zeros(N,channelCount,’double’)));
switch channelCount
case 2
x_in(1:N,1) = ch0(1:N);
x_in(1:N,2) = ch1(1:N);
case 4
x_in(1:N,1) = ch0(1:N);
x_in(1:N,2) = ch1(1:N);
x_in(1:N,3) = ch2(1:N);
x_in(1:N,4) = ch3(1:N);
end
R = (x_in’ * x_in); % Compute cross-correlation matrix
Here is the C++ codegen result:
void xcorr_matrix(const creal32_T ch0_data[], const int ch0_size[1], % all the 4 ch_size will be the same value
const creal32_T ch1_data[], const int ch1_size[1],
const creal32_T ch2_data[], const int ch2_size[1],
const creal32_T ch3_data[], const int ch3_size[1],
int channelCount,
::coder::array<creal_T, 2U> &R)
{
::coder::array<creal_T, 2U> x_in;
R.set_size(channelCount, channelCount);
x_in.set_size(N, channelCount);
…
}
I think I can eliminate the x_in.set_size by not using x_in, and replace the matrix multiply with nested for-loops and using double casting; but am unsure how to define R (either 2×2 or 4×4) so as to remove the R.set_size allocations.
One idea I had was to try making R a fixed length 16 element vector, and just use 4 elements for the 2×2 R, and all 16 for the 4×4 R. Would be nicer to be able to use two indices for rows and columns.
Thanks in advance for your help.
PaulI do not want any dynamic memory allocation to be done in the C++ codegen. Here is the relevant Matlab code:
% Calculate cross-correlation matrix from a set of vectors (whose length
% can vary from one call to another). All 4 channels will have the length.
function [R] = xcorr_matrix(ch0,ch1,ch2,ch3,channelCount)
% channelCount is 2 or 4
% R is either 2×2 or 4×4 complex double matrix.
% ch0 … ch3 are complex single vectors.
N = int32(size(ch0,1));
% Convert ch0, …, ch3 to complex double
x_in = coder.nullcopy(complex(zeros(N,channelCount,’double’)));
switch channelCount
case 2
x_in(1:N,1) = ch0(1:N);
x_in(1:N,2) = ch1(1:N);
case 4
x_in(1:N,1) = ch0(1:N);
x_in(1:N,2) = ch1(1:N);
x_in(1:N,3) = ch2(1:N);
x_in(1:N,4) = ch3(1:N);
end
R = (x_in’ * x_in); % Compute cross-correlation matrix
Here is the C++ codegen result:
void xcorr_matrix(const creal32_T ch0_data[], const int ch0_size[1], % all the 4 ch_size will be the same value
const creal32_T ch1_data[], const int ch1_size[1],
const creal32_T ch2_data[], const int ch2_size[1],
const creal32_T ch3_data[], const int ch3_size[1],
int channelCount,
::coder::array<creal_T, 2U> &R)
{
::coder::array<creal_T, 2U> x_in;
R.set_size(channelCount, channelCount);
x_in.set_size(N, channelCount);
…
}
I think I can eliminate the x_in.set_size by not using x_in, and replace the matrix multiply with nested for-loops and using double casting; but am unsure how to define R (either 2×2 or 4×4) so as to remove the R.set_size allocations.
One idea I had was to try making R a fixed length 16 element vector, and just use 4 elements for the 2×2 R, and all 16 for the 4×4 R. Would be nicer to be able to use two indices for rows and columns.
Thanks in advance for your help.
Paul I do not want any dynamic memory allocation to be done in the C++ codegen. Here is the relevant Matlab code:
% Calculate cross-correlation matrix from a set of vectors (whose length
% can vary from one call to another). All 4 channels will have the length.
function [R] = xcorr_matrix(ch0,ch1,ch2,ch3,channelCount)
% channelCount is 2 or 4
% R is either 2×2 or 4×4 complex double matrix.
% ch0 … ch3 are complex single vectors.
N = int32(size(ch0,1));
% Convert ch0, …, ch3 to complex double
x_in = coder.nullcopy(complex(zeros(N,channelCount,’double’)));
switch channelCount
case 2
x_in(1:N,1) = ch0(1:N);
x_in(1:N,2) = ch1(1:N);
case 4
x_in(1:N,1) = ch0(1:N);
x_in(1:N,2) = ch1(1:N);
x_in(1:N,3) = ch2(1:N);
x_in(1:N,4) = ch3(1:N);
end
R = (x_in’ * x_in); % Compute cross-correlation matrix
Here is the C++ codegen result:
void xcorr_matrix(const creal32_T ch0_data[], const int ch0_size[1], % all the 4 ch_size will be the same value
const creal32_T ch1_data[], const int ch1_size[1],
const creal32_T ch2_data[], const int ch2_size[1],
const creal32_T ch3_data[], const int ch3_size[1],
int channelCount,
::coder::array<creal_T, 2U> &R)
{
::coder::array<creal_T, 2U> x_in;
R.set_size(channelCount, channelCount);
x_in.set_size(N, channelCount);
…
}
I think I can eliminate the x_in.set_size by not using x_in, and replace the matrix multiply with nested for-loops and using double casting; but am unsure how to define R (either 2×2 or 4×4) so as to remove the R.set_size allocations.
One idea I had was to try making R a fixed length 16 element vector, and just use 4 elements for the 2×2 R, and all 16 for the 4×4 R. Would be nicer to be able to use two indices for rows and columns.
Thanks in advance for your help.
Paul matlab, codegen, embedded coder, c++, dynamic memory allocation MATLAB Answers — New Questions
Speed up nested loops with parfor
I’m trying to speed up this part of code. I have a constraint: the inputs of ReturnFn must all be scalars. If it was not for this restriction, I could easily vectorize the code. So I would like to know if there is a way to make the code below faster, while still satisfying this restriction of the inputs of ReturnFn.
Any help is really appreciated!
N_d = 50;
N_a = 300;
N_z = 10;
% ParamCell contains: K_to_L,alpha,delta,pen,gamma,crra
% I need the cell array to handle variable number of inputs in ReturnFn
Fmatrix=zeros(N_d*N_a,N_a,N_z);
parfor i4i5=1:N_z
Fmatrix_z=zeros(N_d*N_a,N_a);
for i3=1:N_a % a today
for i2=1:N_a % a’ tomorrow
for i1=1:N_d % d choice
Fmatrix_z(i1+(i2-1)*N_d,i3)=ReturnFn(d_gridvals(i1),a_gridvals(i2),a_gridvals(i3),z_gridvals(i4i5,1),z_gridvals(i4i5,2),ParamCell{:});
end
end
end
Fmatrix(:,:,i4i5)=Fmatrix_z;
end
function F = f_ReturnFn(d,aprime,a,e,age,K_to_L,alpha,delta,pen,gamma,crra)
% INPUTS (always 5 inputs, plus some extra parameter inputs)
% d: Hours worked
% aprime: Next-period’s assets
% a: Current period assets
% e: Labor efficiency shock
% age: Age of individual: young or old
% TOOLKIT NOTATION
% (d,aprime,a,z), where z = [e;age]
F = -inf;
r = alpha*K_to_L^(alpha-1)-delta;
w = (1-alpha)*K_to_L^alpha;
income = (w*e*d)*(age==1)+pen*(age==2)+r*a;
c = income+a-aprime; % Budget Constraint
if c>0
% NOTE: 0<d<1 is already built into the grid
% WARNING: this will not work if crra=1
inside = (c^gamma)*((1-d)^(1-gamma));
F = inside^(1-crra)/(1-crra);
end
endI’m trying to speed up this part of code. I have a constraint: the inputs of ReturnFn must all be scalars. If it was not for this restriction, I could easily vectorize the code. So I would like to know if there is a way to make the code below faster, while still satisfying this restriction of the inputs of ReturnFn.
Any help is really appreciated!
N_d = 50;
N_a = 300;
N_z = 10;
% ParamCell contains: K_to_L,alpha,delta,pen,gamma,crra
% I need the cell array to handle variable number of inputs in ReturnFn
Fmatrix=zeros(N_d*N_a,N_a,N_z);
parfor i4i5=1:N_z
Fmatrix_z=zeros(N_d*N_a,N_a);
for i3=1:N_a % a today
for i2=1:N_a % a’ tomorrow
for i1=1:N_d % d choice
Fmatrix_z(i1+(i2-1)*N_d,i3)=ReturnFn(d_gridvals(i1),a_gridvals(i2),a_gridvals(i3),z_gridvals(i4i5,1),z_gridvals(i4i5,2),ParamCell{:});
end
end
end
Fmatrix(:,:,i4i5)=Fmatrix_z;
end
function F = f_ReturnFn(d,aprime,a,e,age,K_to_L,alpha,delta,pen,gamma,crra)
% INPUTS (always 5 inputs, plus some extra parameter inputs)
% d: Hours worked
% aprime: Next-period’s assets
% a: Current period assets
% e: Labor efficiency shock
% age: Age of individual: young or old
% TOOLKIT NOTATION
% (d,aprime,a,z), where z = [e;age]
F = -inf;
r = alpha*K_to_L^(alpha-1)-delta;
w = (1-alpha)*K_to_L^alpha;
income = (w*e*d)*(age==1)+pen*(age==2)+r*a;
c = income+a-aprime; % Budget Constraint
if c>0
% NOTE: 0<d<1 is already built into the grid
% WARNING: this will not work if crra=1
inside = (c^gamma)*((1-d)^(1-gamma));
F = inside^(1-crra)/(1-crra);
end
end I’m trying to speed up this part of code. I have a constraint: the inputs of ReturnFn must all be scalars. If it was not for this restriction, I could easily vectorize the code. So I would like to know if there is a way to make the code below faster, while still satisfying this restriction of the inputs of ReturnFn.
Any help is really appreciated!
N_d = 50;
N_a = 300;
N_z = 10;
% ParamCell contains: K_to_L,alpha,delta,pen,gamma,crra
% I need the cell array to handle variable number of inputs in ReturnFn
Fmatrix=zeros(N_d*N_a,N_a,N_z);
parfor i4i5=1:N_z
Fmatrix_z=zeros(N_d*N_a,N_a);
for i3=1:N_a % a today
for i2=1:N_a % a’ tomorrow
for i1=1:N_d % d choice
Fmatrix_z(i1+(i2-1)*N_d,i3)=ReturnFn(d_gridvals(i1),a_gridvals(i2),a_gridvals(i3),z_gridvals(i4i5,1),z_gridvals(i4i5,2),ParamCell{:});
end
end
end
Fmatrix(:,:,i4i5)=Fmatrix_z;
end
function F = f_ReturnFn(d,aprime,a,e,age,K_to_L,alpha,delta,pen,gamma,crra)
% INPUTS (always 5 inputs, plus some extra parameter inputs)
% d: Hours worked
% aprime: Next-period’s assets
% a: Current period assets
% e: Labor efficiency shock
% age: Age of individual: young or old
% TOOLKIT NOTATION
% (d,aprime,a,z), where z = [e;age]
F = -inf;
r = alpha*K_to_L^(alpha-1)-delta;
w = (1-alpha)*K_to_L^alpha;
income = (w*e*d)*(age==1)+pen*(age==2)+r*a;
c = income+a-aprime; % Budget Constraint
if c>0
% NOTE: 0<d<1 is already built into the grid
% WARNING: this will not work if crra=1
inside = (c^gamma)*((1-d)^(1-gamma));
F = inside^(1-crra)/(1-crra);
end
end nested loops, parfor MATLAB Answers — New Questions