Category: Matlab
Category Archives: Matlab
Function dnlim unrecognized.
I am trying to build a subsuircuit library using a netlist of ADCMP604 in matlab. The netlist is given below. On running the following commands :
subcircuit2ssc(‘ADCMP604.cir’,’+comp_1′);
ssc_build comp_1;
I am getting the following error:
>> convert3
Error using spiceSubckt/getFunctionCalls
Function dnlim unrecognized.
Error in spiceSubckt/loadSubckt
Error in spiceSubckt
Error in subcircuit2ssc
Error in subcircuit2ssc (line 31)
subcircuit2ssc(netlist,target);
Error in convert3 (line 1)
subcircuit2ssc(‘ADCMP604.cir’,’+comp_1′);
How do I resolve this?
* ADCMP604 SPICE Macro-model – BETA
* Description: RR, 2.5 to 5.5V, SS, LVDS Comparator
* Developed by: AR/ADGT
* Revision History:
* 1.0 (1/2021) – AR – BETA release
* Copyright (c) 1998-2021 Analog Devices, Inc. All rights reserved.
* Not Modeled:
* Temperature effects
* PSRR vs Frequency
* CMRR vs Frequency
*
* Parameters modeled include:
* VOS
* IVR
* Input Impedance
* Active Gain
* VOD
* AC Performance
* Supply Range and Current
*
* This is a BETA model only.
* This is not the final model.
*
* Node Assignments
* Q
* | VEE
* | | Vp
* | | | Vn
* | | | | VCCI/VCCO
* | | | | | QB
* | | | | | |
.subckt ADCMP604 1 2 3 4 5 6
B1 0 VDIN I=10u*dnlim(uplim(V(3),V(5)+.2,.1), V(2)-.5 ,.1)+1n*V(3)
B2 VDIN 0 I=10u*dnlim(uplim(V(4),V(5)+.2,.1), V(2)-.5, .1)+1n*V(4)
C1 VDIN 0 .5f Rpar=470k
D5 0 VDH0 DLAT
C4 4 2 1p Rpar=370k
C10 3 2 1p Rpar=370k
C7 5 1 200f
C8 1 2 200f
A6 N004 0 N002 0 0 0 VDH0 0 OTA g=500u linear Vlow=-1e308 Vhigh=1e308
D6 0 N004 DLAT
C3 N004 0 1p
G1 0 N004 0 VDH0 500µ
R4 N001 N003 14.5k
A8 N001 2 0 0 0 N002 0 0 SCHMITT vt=.4 vh=0 trise=1n tfall=1.5n
D1 VDIN 0 DVGAIN
D3 N003 2 DBLE
D2 5 4 DBIASR
D4 4 2 DBIASF
D7 5 3 DBIASR
D8 3 2 DBIASF
C15 5 6 200f
C16 6 2 200f
D10 5 2 DBURNSDI
R1 5 2 19.2k
D11 5 2 DBURNSDO
D12 2 6 DESD
D13 6 5 DESD
D14 1 5 DESD
D15 2 1 DESD
D17 4 5 DESD
D16 2 4 DESD
D18 4 3 DBIASC
D9 3 5 DESD
D19 2 3 DESD
R2 1 Vcm 10Meg
R5 Vcm 6 10Meg
M1 N010 N010 2 2 NPD
M2 1 N010 2 2 NPD M=100
B4 2 N010 I=(17.5u+1u*V(0))*(1-V(VDH))
D22 2 N010 DLIM1
M3 N008 N008 5 5 PPU
M4 1 N008 5 5 PPU M=100
B5 N008 5 I=(17.5u-1u*V(0))*(V(VDH)+1)
D23 N008 5 DLIM1
M5 N012 N012 2 2 NPD
M6 6 N012 2 2 NPD M=100
B6 2 N012 I=(17.5u+1u*V(0))*(V(VDH)+1)
D24 2 N012 DLIM1
M7 N011 N011 5 5 PPU
M8 6 N011 5 5 PPU M=100
B7 N011 5 I=(17.5u-1u*V(0))*(1-V(VDH))
D25 N011 5 DLIM1
C2 VDH0 0 40f
B8 0 VDH0 I=100u*tanh(V(VDIN)/50m)*uplim(dnlim(100m*V(5,2)+1,1,.1),1.5,.1)
A2 0 VDH0 0 0 0 0 VDH 0 OTA g=6.5m iout=5m Rout=1k Cout=700f vlow=-1 vhigh=1
C9 VDH0 0 q=120f*dnlim(x,.7,.1)**1.5-100f*dnlim(-x,.7,.1)**1.5
D26 VDIN 0 DVLIM
C12 1 6 3p
A3 2 Vcm 0 0 0 0 0 0 OTA g=100m iout=17.5u ref=-1.26 Rout=1Meg Cout=1f vlow=-1e308 vhigh=1e308
C13 5 2 5p Rpar=83k
C14 N001 2 1p Rpar=100
I1 2 N001 12.52m
S1 2 5 5 0 SVDDP
.model SVDDP SW(level=2 Ron=10 Roff=100Meg vt=.5 vh=-.2 ilimit=10.36m)
.model DVGAIN D(Ron=15k Roff=2Meg vfwd=15.3m epsilon=10m vrev=15.3m revepsilon=10m)
.model DVLIM D(Ron=1k Roff=100Meg vfwd=60m epsilon=10m vrev=60m revepsilon=10m)
.model DBLE D(Ron=31k Roff=1Meg vfwd=1.3 epsilon=100m)
.model DLAT D(Ron=1 Roff=76k Vfwd=1 Vrev=1 epsilon=.9 revepsilon=.9)
.model DBIASF D(Ron=300k Roff=1G vfwd=-400m epsilon=200m ilimit=2u )
.model DBIASR D(Ron=80k Roff=1G vfwd=1 epsilon=150m ilimit=2u )
.model DESD D(Ron=100 Roff=1G vfwd=650m epsilon=500m)
.model DBURNSDI D(Ron=100 Roff=1Meg vfwd=1.6 epsilon=500m ilimit=500u)
.model DBURNSDO D(Ron=100 Roff=1Meg vfwd=1.6 epsilon=500m ilimit=209u)
.model DP D(Ron=1000 Roff=1Meg vfwd=1.6 epsilon=500m ilimit=20m)
.model DBIASC D(Roff=100Meg Ron=750k vfwd=10u vrev=10u epsilon=10u revepsilon=10u ilimit=1u revilimit=1u)
.model NPD VDMOS(kp=72.45u ksubthres=.1 vto=1)
.model PPU VDMOS(kp=72.45u vto=-1 ksubthres=.1 pchan)
.model DLIM1 D(Ron=100 Roff=1G vfwd=1 epsilon=500m)
.model DSHT D(Ron=10k Roff=100Meg vfwd=2.2 epsilon=500m ilimit=.8u)
.ends ADCMP604I am trying to build a subsuircuit library using a netlist of ADCMP604 in matlab. The netlist is given below. On running the following commands :
subcircuit2ssc(‘ADCMP604.cir’,’+comp_1′);
ssc_build comp_1;
I am getting the following error:
>> convert3
Error using spiceSubckt/getFunctionCalls
Function dnlim unrecognized.
Error in spiceSubckt/loadSubckt
Error in spiceSubckt
Error in subcircuit2ssc
Error in subcircuit2ssc (line 31)
subcircuit2ssc(netlist,target);
Error in convert3 (line 1)
subcircuit2ssc(‘ADCMP604.cir’,’+comp_1′);
How do I resolve this?
* ADCMP604 SPICE Macro-model – BETA
* Description: RR, 2.5 to 5.5V, SS, LVDS Comparator
* Developed by: AR/ADGT
* Revision History:
* 1.0 (1/2021) – AR – BETA release
* Copyright (c) 1998-2021 Analog Devices, Inc. All rights reserved.
* Not Modeled:
* Temperature effects
* PSRR vs Frequency
* CMRR vs Frequency
*
* Parameters modeled include:
* VOS
* IVR
* Input Impedance
* Active Gain
* VOD
* AC Performance
* Supply Range and Current
*
* This is a BETA model only.
* This is not the final model.
*
* Node Assignments
* Q
* | VEE
* | | Vp
* | | | Vn
* | | | | VCCI/VCCO
* | | | | | QB
* | | | | | |
.subckt ADCMP604 1 2 3 4 5 6
B1 0 VDIN I=10u*dnlim(uplim(V(3),V(5)+.2,.1), V(2)-.5 ,.1)+1n*V(3)
B2 VDIN 0 I=10u*dnlim(uplim(V(4),V(5)+.2,.1), V(2)-.5, .1)+1n*V(4)
C1 VDIN 0 .5f Rpar=470k
D5 0 VDH0 DLAT
C4 4 2 1p Rpar=370k
C10 3 2 1p Rpar=370k
C7 5 1 200f
C8 1 2 200f
A6 N004 0 N002 0 0 0 VDH0 0 OTA g=500u linear Vlow=-1e308 Vhigh=1e308
D6 0 N004 DLAT
C3 N004 0 1p
G1 0 N004 0 VDH0 500µ
R4 N001 N003 14.5k
A8 N001 2 0 0 0 N002 0 0 SCHMITT vt=.4 vh=0 trise=1n tfall=1.5n
D1 VDIN 0 DVGAIN
D3 N003 2 DBLE
D2 5 4 DBIASR
D4 4 2 DBIASF
D7 5 3 DBIASR
D8 3 2 DBIASF
C15 5 6 200f
C16 6 2 200f
D10 5 2 DBURNSDI
R1 5 2 19.2k
D11 5 2 DBURNSDO
D12 2 6 DESD
D13 6 5 DESD
D14 1 5 DESD
D15 2 1 DESD
D17 4 5 DESD
D16 2 4 DESD
D18 4 3 DBIASC
D9 3 5 DESD
D19 2 3 DESD
R2 1 Vcm 10Meg
R5 Vcm 6 10Meg
M1 N010 N010 2 2 NPD
M2 1 N010 2 2 NPD M=100
B4 2 N010 I=(17.5u+1u*V(0))*(1-V(VDH))
D22 2 N010 DLIM1
M3 N008 N008 5 5 PPU
M4 1 N008 5 5 PPU M=100
B5 N008 5 I=(17.5u-1u*V(0))*(V(VDH)+1)
D23 N008 5 DLIM1
M5 N012 N012 2 2 NPD
M6 6 N012 2 2 NPD M=100
B6 2 N012 I=(17.5u+1u*V(0))*(V(VDH)+1)
D24 2 N012 DLIM1
M7 N011 N011 5 5 PPU
M8 6 N011 5 5 PPU M=100
B7 N011 5 I=(17.5u-1u*V(0))*(1-V(VDH))
D25 N011 5 DLIM1
C2 VDH0 0 40f
B8 0 VDH0 I=100u*tanh(V(VDIN)/50m)*uplim(dnlim(100m*V(5,2)+1,1,.1),1.5,.1)
A2 0 VDH0 0 0 0 0 VDH 0 OTA g=6.5m iout=5m Rout=1k Cout=700f vlow=-1 vhigh=1
C9 VDH0 0 q=120f*dnlim(x,.7,.1)**1.5-100f*dnlim(-x,.7,.1)**1.5
D26 VDIN 0 DVLIM
C12 1 6 3p
A3 2 Vcm 0 0 0 0 0 0 OTA g=100m iout=17.5u ref=-1.26 Rout=1Meg Cout=1f vlow=-1e308 vhigh=1e308
C13 5 2 5p Rpar=83k
C14 N001 2 1p Rpar=100
I1 2 N001 12.52m
S1 2 5 5 0 SVDDP
.model SVDDP SW(level=2 Ron=10 Roff=100Meg vt=.5 vh=-.2 ilimit=10.36m)
.model DVGAIN D(Ron=15k Roff=2Meg vfwd=15.3m epsilon=10m vrev=15.3m revepsilon=10m)
.model DVLIM D(Ron=1k Roff=100Meg vfwd=60m epsilon=10m vrev=60m revepsilon=10m)
.model DBLE D(Ron=31k Roff=1Meg vfwd=1.3 epsilon=100m)
.model DLAT D(Ron=1 Roff=76k Vfwd=1 Vrev=1 epsilon=.9 revepsilon=.9)
.model DBIASF D(Ron=300k Roff=1G vfwd=-400m epsilon=200m ilimit=2u )
.model DBIASR D(Ron=80k Roff=1G vfwd=1 epsilon=150m ilimit=2u )
.model DESD D(Ron=100 Roff=1G vfwd=650m epsilon=500m)
.model DBURNSDI D(Ron=100 Roff=1Meg vfwd=1.6 epsilon=500m ilimit=500u)
.model DBURNSDO D(Ron=100 Roff=1Meg vfwd=1.6 epsilon=500m ilimit=209u)
.model DP D(Ron=1000 Roff=1Meg vfwd=1.6 epsilon=500m ilimit=20m)
.model DBIASC D(Roff=100Meg Ron=750k vfwd=10u vrev=10u epsilon=10u revepsilon=10u ilimit=1u revilimit=1u)
.model NPD VDMOS(kp=72.45u ksubthres=.1 vto=1)
.model PPU VDMOS(kp=72.45u vto=-1 ksubthres=.1 pchan)
.model DLIM1 D(Ron=100 Roff=1G vfwd=1 epsilon=500m)
.model DSHT D(Ron=10k Roff=100Meg vfwd=2.2 epsilon=500m ilimit=.8u)
.ends ADCMP604 I am trying to build a subsuircuit library using a netlist of ADCMP604 in matlab. The netlist is given below. On running the following commands :
subcircuit2ssc(‘ADCMP604.cir’,’+comp_1′);
ssc_build comp_1;
I am getting the following error:
>> convert3
Error using spiceSubckt/getFunctionCalls
Function dnlim unrecognized.
Error in spiceSubckt/loadSubckt
Error in spiceSubckt
Error in subcircuit2ssc
Error in subcircuit2ssc (line 31)
subcircuit2ssc(netlist,target);
Error in convert3 (line 1)
subcircuit2ssc(‘ADCMP604.cir’,’+comp_1′);
How do I resolve this?
* ADCMP604 SPICE Macro-model – BETA
* Description: RR, 2.5 to 5.5V, SS, LVDS Comparator
* Developed by: AR/ADGT
* Revision History:
* 1.0 (1/2021) – AR – BETA release
* Copyright (c) 1998-2021 Analog Devices, Inc. All rights reserved.
* Not Modeled:
* Temperature effects
* PSRR vs Frequency
* CMRR vs Frequency
*
* Parameters modeled include:
* VOS
* IVR
* Input Impedance
* Active Gain
* VOD
* AC Performance
* Supply Range and Current
*
* This is a BETA model only.
* This is not the final model.
*
* Node Assignments
* Q
* | VEE
* | | Vp
* | | | Vn
* | | | | VCCI/VCCO
* | | | | | QB
* | | | | | |
.subckt ADCMP604 1 2 3 4 5 6
B1 0 VDIN I=10u*dnlim(uplim(V(3),V(5)+.2,.1), V(2)-.5 ,.1)+1n*V(3)
B2 VDIN 0 I=10u*dnlim(uplim(V(4),V(5)+.2,.1), V(2)-.5, .1)+1n*V(4)
C1 VDIN 0 .5f Rpar=470k
D5 0 VDH0 DLAT
C4 4 2 1p Rpar=370k
C10 3 2 1p Rpar=370k
C7 5 1 200f
C8 1 2 200f
A6 N004 0 N002 0 0 0 VDH0 0 OTA g=500u linear Vlow=-1e308 Vhigh=1e308
D6 0 N004 DLAT
C3 N004 0 1p
G1 0 N004 0 VDH0 500µ
R4 N001 N003 14.5k
A8 N001 2 0 0 0 N002 0 0 SCHMITT vt=.4 vh=0 trise=1n tfall=1.5n
D1 VDIN 0 DVGAIN
D3 N003 2 DBLE
D2 5 4 DBIASR
D4 4 2 DBIASF
D7 5 3 DBIASR
D8 3 2 DBIASF
C15 5 6 200f
C16 6 2 200f
D10 5 2 DBURNSDI
R1 5 2 19.2k
D11 5 2 DBURNSDO
D12 2 6 DESD
D13 6 5 DESD
D14 1 5 DESD
D15 2 1 DESD
D17 4 5 DESD
D16 2 4 DESD
D18 4 3 DBIASC
D9 3 5 DESD
D19 2 3 DESD
R2 1 Vcm 10Meg
R5 Vcm 6 10Meg
M1 N010 N010 2 2 NPD
M2 1 N010 2 2 NPD M=100
B4 2 N010 I=(17.5u+1u*V(0))*(1-V(VDH))
D22 2 N010 DLIM1
M3 N008 N008 5 5 PPU
M4 1 N008 5 5 PPU M=100
B5 N008 5 I=(17.5u-1u*V(0))*(V(VDH)+1)
D23 N008 5 DLIM1
M5 N012 N012 2 2 NPD
M6 6 N012 2 2 NPD M=100
B6 2 N012 I=(17.5u+1u*V(0))*(V(VDH)+1)
D24 2 N012 DLIM1
M7 N011 N011 5 5 PPU
M8 6 N011 5 5 PPU M=100
B7 N011 5 I=(17.5u-1u*V(0))*(1-V(VDH))
D25 N011 5 DLIM1
C2 VDH0 0 40f
B8 0 VDH0 I=100u*tanh(V(VDIN)/50m)*uplim(dnlim(100m*V(5,2)+1,1,.1),1.5,.1)
A2 0 VDH0 0 0 0 0 VDH 0 OTA g=6.5m iout=5m Rout=1k Cout=700f vlow=-1 vhigh=1
C9 VDH0 0 q=120f*dnlim(x,.7,.1)**1.5-100f*dnlim(-x,.7,.1)**1.5
D26 VDIN 0 DVLIM
C12 1 6 3p
A3 2 Vcm 0 0 0 0 0 0 OTA g=100m iout=17.5u ref=-1.26 Rout=1Meg Cout=1f vlow=-1e308 vhigh=1e308
C13 5 2 5p Rpar=83k
C14 N001 2 1p Rpar=100
I1 2 N001 12.52m
S1 2 5 5 0 SVDDP
.model SVDDP SW(level=2 Ron=10 Roff=100Meg vt=.5 vh=-.2 ilimit=10.36m)
.model DVGAIN D(Ron=15k Roff=2Meg vfwd=15.3m epsilon=10m vrev=15.3m revepsilon=10m)
.model DVLIM D(Ron=1k Roff=100Meg vfwd=60m epsilon=10m vrev=60m revepsilon=10m)
.model DBLE D(Ron=31k Roff=1Meg vfwd=1.3 epsilon=100m)
.model DLAT D(Ron=1 Roff=76k Vfwd=1 Vrev=1 epsilon=.9 revepsilon=.9)
.model DBIASF D(Ron=300k Roff=1G vfwd=-400m epsilon=200m ilimit=2u )
.model DBIASR D(Ron=80k Roff=1G vfwd=1 epsilon=150m ilimit=2u )
.model DESD D(Ron=100 Roff=1G vfwd=650m epsilon=500m)
.model DBURNSDI D(Ron=100 Roff=1Meg vfwd=1.6 epsilon=500m ilimit=500u)
.model DBURNSDO D(Ron=100 Roff=1Meg vfwd=1.6 epsilon=500m ilimit=209u)
.model DP D(Ron=1000 Roff=1Meg vfwd=1.6 epsilon=500m ilimit=20m)
.model DBIASC D(Roff=100Meg Ron=750k vfwd=10u vrev=10u epsilon=10u revepsilon=10u ilimit=1u revilimit=1u)
.model NPD VDMOS(kp=72.45u ksubthres=.1 vto=1)
.model PPU VDMOS(kp=72.45u vto=-1 ksubthres=.1 pchan)
.model DLIM1 D(Ron=100 Roff=1G vfwd=1 epsilon=500m)
.model DSHT D(Ron=10k Roff=100Meg vfwd=2.2 epsilon=500m ilimit=.8u)
.ends ADCMP604 matlab, simscape MATLAB Answers — New Questions
Why does the MATLAB Web App Server service fail to start?
I am using MATLAB Web App Server (product version). When I attempt to start my server using webapps-start or webapps-restart, I receive the following error:
MATLAB Web App Server service failed to start.
Check the logs files for more information:
C:ProgramDataMathWorkswebappsR2024alogswebapps_<timestamp>.log
C:ProgramDataMathWorkswebappsR2024alogswebapps_service_start.err
C:ProgramDataMathWorkswebappsR2024alogswebapps_service_start.out
How do I troubleshoot this?I am using MATLAB Web App Server (product version). When I attempt to start my server using webapps-start or webapps-restart, I receive the following error:
MATLAB Web App Server service failed to start.
Check the logs files for more information:
C:ProgramDataMathWorkswebappsR2024alogswebapps_<timestamp>.log
C:ProgramDataMathWorkswebappsR2024alogswebapps_service_start.err
C:ProgramDataMathWorkswebappsR2024alogswebapps_service_start.out
How do I troubleshoot this? I am using MATLAB Web App Server (product version). When I attempt to start my server using webapps-start or webapps-restart, I receive the following error:
MATLAB Web App Server service failed to start.
Check the logs files for more information:
C:ProgramDataMathWorkswebappsR2024alogswebapps_<timestamp>.log
C:ProgramDataMathWorkswebappsR2024alogswebapps_service_start.err
C:ProgramDataMathWorkswebappsR2024alogswebapps_service_start.out
How do I troubleshoot this? webappserver, startup MATLAB Answers — New Questions
Readjust a camera data set
I have a data set of size 2000*300*20. It is a data from a camera with 2000 pixel.
I want to extract out the last data set in the x and y cordinates i.e. at 300 and 20.
Afterwards, I want to use it to replace all the data points of all other x and y components.
I have made some attempts but with no success, I will attached my code for any for useful comments. Thanks
m=size(A.Volume); % A data of size; 2000*300*20
new_A.Volume=A.Volume;
for i = 1:m(2);
for j = 1:m(3);
new_A.Volume(i, j)=A.Volume(:,m(2),m(3));
end
endI have a data set of size 2000*300*20. It is a data from a camera with 2000 pixel.
I want to extract out the last data set in the x and y cordinates i.e. at 300 and 20.
Afterwards, I want to use it to replace all the data points of all other x and y components.
I have made some attempts but with no success, I will attached my code for any for useful comments. Thanks
m=size(A.Volume); % A data of size; 2000*300*20
new_A.Volume=A.Volume;
for i = 1:m(2);
for j = 1:m(3);
new_A.Volume(i, j)=A.Volume(:,m(2),m(3));
end
end I have a data set of size 2000*300*20. It is a data from a camera with 2000 pixel.
I want to extract out the last data set in the x and y cordinates i.e. at 300 and 20.
Afterwards, I want to use it to replace all the data points of all other x and y components.
I have made some attempts but with no success, I will attached my code for any for useful comments. Thanks
m=size(A.Volume); % A data of size; 2000*300*20
new_A.Volume=A.Volume;
for i = 1:m(2);
for j = 1:m(3);
new_A.Volume(i, j)=A.Volume(:,m(2),m(3));
end
end readjust a camera data set MATLAB Answers — New Questions
Building C Code of Simulink Model with UDP Send/Receive
Hi all,
I am about to build Simulink models utilizing the "UDP Send" or "UDP Receive" blocks from the DSP System Toolbox.
I am not building an executable (*.exe) from the Simulink Model directly. The source and header files generated in the "…grt_rtw" are referenced in further code that comes from our inhouse software toolchain…
The overall building toolchain works for many other models / applications. Only now, as i am playing around with the UDP blocks I am receiving a linker error (LNK2019 unresolved external symbol) when building the code in Visual Studio.
Is it even possible to use the "UDP Send" and "UDP Receive" blocks for code generation other than building an *.exe?
I have referenced the DAHhostLib_network.h and *.rtw.h as well as the *.c files.
I understand, that the networkdevice.dll is cruicial for this to be working. According to one of our IT guys, I am in need of a *.lib file to link to that *.dll? But we couldn’t find any.
Thank you for any help! Would be great to get this running somehow 🙂
Best,
RaphaelHi all,
I am about to build Simulink models utilizing the "UDP Send" or "UDP Receive" blocks from the DSP System Toolbox.
I am not building an executable (*.exe) from the Simulink Model directly. The source and header files generated in the "…grt_rtw" are referenced in further code that comes from our inhouse software toolchain…
The overall building toolchain works for many other models / applications. Only now, as i am playing around with the UDP blocks I am receiving a linker error (LNK2019 unresolved external symbol) when building the code in Visual Studio.
Is it even possible to use the "UDP Send" and "UDP Receive" blocks for code generation other than building an *.exe?
I have referenced the DAHhostLib_network.h and *.rtw.h as well as the *.c files.
I understand, that the networkdevice.dll is cruicial for this to be working. According to one of our IT guys, I am in need of a *.lib file to link to that *.dll? But we couldn’t find any.
Thank you for any help! Would be great to get this running somehow 🙂
Best,
Raphael Hi all,
I am about to build Simulink models utilizing the "UDP Send" or "UDP Receive" blocks from the DSP System Toolbox.
I am not building an executable (*.exe) from the Simulink Model directly. The source and header files generated in the "…grt_rtw" are referenced in further code that comes from our inhouse software toolchain…
The overall building toolchain works for many other models / applications. Only now, as i am playing around with the UDP blocks I am receiving a linker error (LNK2019 unresolved external symbol) when building the code in Visual Studio.
Is it even possible to use the "UDP Send" and "UDP Receive" blocks for code generation other than building an *.exe?
I have referenced the DAHhostLib_network.h and *.rtw.h as well as the *.c files.
I understand, that the networkdevice.dll is cruicial for this to be working. According to one of our IT guys, I am in need of a *.lib file to link to that *.dll? But we couldn’t find any.
Thank you for any help! Would be great to get this running somehow 🙂
Best,
Raphael udp, networkdevice.dll MATLAB Answers — New Questions
For Loop Increment Array
I am currently in class and trying to do my assignment. For this assignment we have to create a for loop that creates an array of 0 through 20 with the even numbers. I wrote the code according to my lesson but it keeps inserting a 0 between each number in the array. Is there something obvious I am missing?
% for loop example
for i = 0:2:20
A(i+1) = i^2;
B(i+1) = i;
endI am currently in class and trying to do my assignment. For this assignment we have to create a for loop that creates an array of 0 through 20 with the even numbers. I wrote the code according to my lesson but it keeps inserting a 0 between each number in the array. Is there something obvious I am missing?
% for loop example
for i = 0:2:20
A(i+1) = i^2;
B(i+1) = i;
end I am currently in class and trying to do my assignment. For this assignment we have to create a for loop that creates an array of 0 through 20 with the even numbers. I wrote the code according to my lesson but it keeps inserting a 0 between each number in the array. Is there something obvious I am missing?
% for loop example
for i = 0:2:20
A(i+1) = i^2;
B(i+1) = i;
end for loop, array, increment MATLAB Answers — New Questions
Is it possible to exit debug mode with shortcut keys?
The debug shortcut keys (F5, F10, F11, etc) in the MATLAB Editor are very useful for debugging, developing, and running code respectively. However, there is no shortcut key for "exit debug mode". Since it is often necessary to terminate debug sessions, an exit debug mode shortcut key would be very useful.The debug shortcut keys (F5, F10, F11, etc) in the MATLAB Editor are very useful for debugging, developing, and running code respectively. However, there is no shortcut key for "exit debug mode". Since it is often necessary to terminate debug sessions, an exit debug mode shortcut key would be very useful. The debug shortcut keys (F5, F10, F11, etc) in the MATLAB Editor are very useful for debugging, developing, and running code respectively. However, there is no shortcut key for "exit debug mode". Since it is often necessary to terminate debug sessions, an exit debug mode shortcut key would be very useful. debug, debugger, exit, quit, dbquit MATLAB Answers — New Questions
How to solve this problem combining sequences and reasoning using code?
An arithmetic sequence:range(4m + 2) , has two elements removed, leaving ( 4m ) elements. These remaining elements are evenly divided into ( m ) groups, with each group containing 4 numbers. After removing the two elements, each of the ( m ) groups must form an arithmetic sequence.how to automatically generates all possible cases of arithmetic sequences obtained by removing two elements from range(4m + 2) when a specific positive integer ( m ) is input, and lists them one by one.
function generateArithmeticSequences(m)
% Generate the original arithmetic sequence
originalSequence = 1:(4*m + 2);
% Generate all combinations of two elements to remove
removeCombinations = nchoosek(originalSequence, 2);
% Preallocate the cell array to store valid cases
validCases = {};
% Loop through all combinations of removals
for i = 1:size(removeCombinations, 1)
% Create a copy of the original sequence without the removed elements
remainingSequence = setdiff(originalSequence, removeCombinations(i, :));
% Check if the remaining sequence can be divided into m groups of 4
% such that each group forms an arithmetic sequence
if isDivisibleIntoArithmeticSequences(remainingSequence, m)
validCases{end+1} = remainingSequence;
end
end
% Display the valid cases
displayValidCases(validCases);
end
% Check function to see if the sequence can be divided into m groups of 4
% where each group is an arithmetic sequence
function result = isDivisibleIntoArithmeticSequences(sequence, m)
result = false;
% Divide the sequence into m groups of 4
groups = mat2cell(sequence, 4*ones(1, m), 4);
% Check if each group forms an arithmetic sequence
for i = 1:m
if ~isArithmeticSequence(groups{i})
return;
end
end
result = true;
end
% Check function to determine if a sequence is an arithmetic sequence
function result = isArithmeticSequence(sequence)
result = false;
if length(sequence) < 4
return;
end
differences = diff(sequence);
if all(differences(1) == differences)
result = true;
end
end
% Function to display the valid cases
function displayValidCases(cases)
for i = 1:length(cases)
disp([‘Case ‘, num2str(i), ‘: ‘, mat2str(cases{i})]);
end
end
The code provided above may not produce the correct answers.An arithmetic sequence:range(4m + 2) , has two elements removed, leaving ( 4m ) elements. These remaining elements are evenly divided into ( m ) groups, with each group containing 4 numbers. After removing the two elements, each of the ( m ) groups must form an arithmetic sequence.how to automatically generates all possible cases of arithmetic sequences obtained by removing two elements from range(4m + 2) when a specific positive integer ( m ) is input, and lists them one by one.
function generateArithmeticSequences(m)
% Generate the original arithmetic sequence
originalSequence = 1:(4*m + 2);
% Generate all combinations of two elements to remove
removeCombinations = nchoosek(originalSequence, 2);
% Preallocate the cell array to store valid cases
validCases = {};
% Loop through all combinations of removals
for i = 1:size(removeCombinations, 1)
% Create a copy of the original sequence without the removed elements
remainingSequence = setdiff(originalSequence, removeCombinations(i, :));
% Check if the remaining sequence can be divided into m groups of 4
% such that each group forms an arithmetic sequence
if isDivisibleIntoArithmeticSequences(remainingSequence, m)
validCases{end+1} = remainingSequence;
end
end
% Display the valid cases
displayValidCases(validCases);
end
% Check function to see if the sequence can be divided into m groups of 4
% where each group is an arithmetic sequence
function result = isDivisibleIntoArithmeticSequences(sequence, m)
result = false;
% Divide the sequence into m groups of 4
groups = mat2cell(sequence, 4*ones(1, m), 4);
% Check if each group forms an arithmetic sequence
for i = 1:m
if ~isArithmeticSequence(groups{i})
return;
end
end
result = true;
end
% Check function to determine if a sequence is an arithmetic sequence
function result = isArithmeticSequence(sequence)
result = false;
if length(sequence) < 4
return;
end
differences = diff(sequence);
if all(differences(1) == differences)
result = true;
end
end
% Function to display the valid cases
function displayValidCases(cases)
for i = 1:length(cases)
disp([‘Case ‘, num2str(i), ‘: ‘, mat2str(cases{i})]);
end
end
The code provided above may not produce the correct answers. An arithmetic sequence:range(4m + 2) , has two elements removed, leaving ( 4m ) elements. These remaining elements are evenly divided into ( m ) groups, with each group containing 4 numbers. After removing the two elements, each of the ( m ) groups must form an arithmetic sequence.how to automatically generates all possible cases of arithmetic sequences obtained by removing two elements from range(4m + 2) when a specific positive integer ( m ) is input, and lists them one by one.
function generateArithmeticSequences(m)
% Generate the original arithmetic sequence
originalSequence = 1:(4*m + 2);
% Generate all combinations of two elements to remove
removeCombinations = nchoosek(originalSequence, 2);
% Preallocate the cell array to store valid cases
validCases = {};
% Loop through all combinations of removals
for i = 1:size(removeCombinations, 1)
% Create a copy of the original sequence without the removed elements
remainingSequence = setdiff(originalSequence, removeCombinations(i, :));
% Check if the remaining sequence can be divided into m groups of 4
% such that each group forms an arithmetic sequence
if isDivisibleIntoArithmeticSequences(remainingSequence, m)
validCases{end+1} = remainingSequence;
end
end
% Display the valid cases
displayValidCases(validCases);
end
% Check function to see if the sequence can be divided into m groups of 4
% where each group is an arithmetic sequence
function result = isDivisibleIntoArithmeticSequences(sequence, m)
result = false;
% Divide the sequence into m groups of 4
groups = mat2cell(sequence, 4*ones(1, m), 4);
% Check if each group forms an arithmetic sequence
for i = 1:m
if ~isArithmeticSequence(groups{i})
return;
end
end
result = true;
end
% Check function to determine if a sequence is an arithmetic sequence
function result = isArithmeticSequence(sequence)
result = false;
if length(sequence) < 4
return;
end
differences = diff(sequence);
if all(differences(1) == differences)
result = true;
end
end
% Function to display the valid cases
function displayValidCases(cases)
for i = 1:length(cases)
disp([‘Case ‘, num2str(i), ‘: ‘, mat2str(cases{i})]);
end
end
The code provided above may not produce the correct answers. arrays, – homework not originally tagged as homework – MATLAB Answers — New Questions
Confusion of IMAQ, get data “logging”
Hello. This is a general question about image aquisition using the imaq tool box. The Matlab documentation uses quite confusing terms such as logging and running. What do these physically mean in simple terms?
I want to enable fast image capture and use a single trigger to e.g. set off the camera to collect 20 images:
vid=getVidObj(app);
n=20; % Snap n Images when triggered
vid.FramesPerTrigger=n;
% Start Camera running (not transferring images yet)
start(vid);
trigger(vid); % This inititates te Camera to collect images
tic;
pause(0.01);
[frame,time]=getdata(vid,n); %Just get n fram
tframes=toc;
My questions are:
1: Before getdata is invoked, and the camera has been triggered, are the images on the camera in some kind of memory or do they stream straight to the RAM
2: When getdata is performed, it returns n=20 frames (images). Where are these actual images, are they in RAM on the PC.
The logging and running terminology doesn’t inform of where the actual image data is.
(Im using a Blackfly FLIR camera with USB3 connectivitiy)
Thanks
JasonHello. This is a general question about image aquisition using the imaq tool box. The Matlab documentation uses quite confusing terms such as logging and running. What do these physically mean in simple terms?
I want to enable fast image capture and use a single trigger to e.g. set off the camera to collect 20 images:
vid=getVidObj(app);
n=20; % Snap n Images when triggered
vid.FramesPerTrigger=n;
% Start Camera running (not transferring images yet)
start(vid);
trigger(vid); % This inititates te Camera to collect images
tic;
pause(0.01);
[frame,time]=getdata(vid,n); %Just get n fram
tframes=toc;
My questions are:
1: Before getdata is invoked, and the camera has been triggered, are the images on the camera in some kind of memory or do they stream straight to the RAM
2: When getdata is performed, it returns n=20 frames (images). Where are these actual images, are they in RAM on the PC.
The logging and running terminology doesn’t inform of where the actual image data is.
(Im using a Blackfly FLIR camera with USB3 connectivitiy)
Thanks
Jason Hello. This is a general question about image aquisition using the imaq tool box. The Matlab documentation uses quite confusing terms such as logging and running. What do these physically mean in simple terms?
I want to enable fast image capture and use a single trigger to e.g. set off the camera to collect 20 images:
vid=getVidObj(app);
n=20; % Snap n Images when triggered
vid.FramesPerTrigger=n;
% Start Camera running (not transferring images yet)
start(vid);
trigger(vid); % This inititates te Camera to collect images
tic;
pause(0.01);
[frame,time]=getdata(vid,n); %Just get n fram
tframes=toc;
My questions are:
1: Before getdata is invoked, and the camera has been triggered, are the images on the camera in some kind of memory or do they stream straight to the RAM
2: When getdata is performed, it returns n=20 frames (images). Where are these actual images, are they in RAM on the PC.
The logging and running terminology doesn’t inform of where the actual image data is.
(Im using a Blackfly FLIR camera with USB3 connectivitiy)
Thanks
Jason imaq, getdata, logging, running MATLAB Answers — New Questions
Shading of viscircles weird behavior
When I export a figure via
exportgraphics(axis,filename);
multiple times, I get the strange behavior that after some exports circles drawn via
viscircles(axis,[x, y],r,’EnhanceVisibility’,true);
are shaded white (just the white circle remains which is shaded to improve visibility).
This worked fine for weeks, but now I added the yellow surface-plot below and now this behavior appears.
Can someone explain why this happens and what to do that the export works (while ‘EnhanceVisibility’, true remains)?When I export a figure via
exportgraphics(axis,filename);
multiple times, I get the strange behavior that after some exports circles drawn via
viscircles(axis,[x, y],r,’EnhanceVisibility’,true);
are shaded white (just the white circle remains which is shaded to improve visibility).
This worked fine for weeks, but now I added the yellow surface-plot below and now this behavior appears.
Can someone explain why this happens and what to do that the export works (while ‘EnhanceVisibility’, true remains)? When I export a figure via
exportgraphics(axis,filename);
multiple times, I get the strange behavior that after some exports circles drawn via
viscircles(axis,[x, y],r,’EnhanceVisibility’,true);
are shaded white (just the white circle remains which is shaded to improve visibility).
This worked fine for weeks, but now I added the yellow surface-plot below and now this behavior appears.
Can someone explain why this happens and what to do that the export works (while ‘EnhanceVisibility’, true remains)? viscircles MATLAB Answers — New Questions
Any suggestion to read multi-channelset SEGD file?
Dear all,
I am recently coding in Matlab to read SEGD files but failed. The main problem is that the SEGD file contains 3 channelsets and their trace lengths are different. I used the code from https://github.com/GeoKylin/Segd2Segy, as a starting point (i.e. segd_read.m). Normally it works fine to read the data of the first channelset given the exact trace number. I would much appreciate if you could give any suggestion.
Below is the data plot using SegdSee software.
Thanks in advance,
Henry ShenDear all,
I am recently coding in Matlab to read SEGD files but failed. The main problem is that the SEGD file contains 3 channelsets and their trace lengths are different. I used the code from https://github.com/GeoKylin/Segd2Segy, as a starting point (i.e. segd_read.m). Normally it works fine to read the data of the first channelset given the exact trace number. I would much appreciate if you could give any suggestion.
Below is the data plot using SegdSee software.
Thanks in advance,
Henry Shen Dear all,
I am recently coding in Matlab to read SEGD files but failed. The main problem is that the SEGD file contains 3 channelsets and their trace lengths are different. I used the code from https://github.com/GeoKylin/Segd2Segy, as a starting point (i.e. segd_read.m). Normally it works fine to read the data of the first channelset given the exact trace number. I would much appreciate if you could give any suggestion.
Below is the data plot using SegdSee software.
Thanks in advance,
Henry Shen segd, matlab, seismic, data processing, read data MATLAB Answers — New Questions
How to structure the data using webread
Hi, I have to automatized a procedure to extract data from different codes and the web link that will be generated is the following:
url=’earthquake.usgs.gov/fdsnws/event/1/query?format=quakeml&eventid=us6000n8tq’,
data=webread(url);
So, data has plenty of information that I would like to structure it for easy ectraction of specific data.
I would appreciate the help.Hi, I have to automatized a procedure to extract data from different codes and the web link that will be generated is the following:
url=’earthquake.usgs.gov/fdsnws/event/1/query?format=quakeml&eventid=us6000n8tq’,
data=webread(url);
So, data has plenty of information that I would like to structure it for easy ectraction of specific data.
I would appreciate the help. Hi, I have to automatized a procedure to extract data from different codes and the web link that will be generated is the following:
url=’earthquake.usgs.gov/fdsnws/event/1/query?format=quakeml&eventid=us6000n8tq’,
data=webread(url);
So, data has plenty of information that I would like to structure it for easy ectraction of specific data.
I would appreciate the help. generate a structure matrix using webread MATLAB Answers — New Questions
How to find two layers to replace in googlenet?
Hello,
I’m trying the deep learning using googlenet and I don’t know how to solve the ‘findLayersToReplace’.
I tried this code but it give 3 layers instead of 2 layers that need to find.
layers = net.Layers(end-2:end);
layers =
3×1 Layer array with layers:
1 ‘loss3-classifier’ Fully Connected 1000 fully connected layer
2 ‘prob’ Softmax softmax
3 ‘output’ Classification Output crossentropyex with ‘tench’ and 999 other classes
I don’t need to replace Softmax layer.
Please help me creating the function of findLayersToReplace.
Thank you very much
Hana RazakHello,
I’m trying the deep learning using googlenet and I don’t know how to solve the ‘findLayersToReplace’.
I tried this code but it give 3 layers instead of 2 layers that need to find.
layers = net.Layers(end-2:end);
layers =
3×1 Layer array with layers:
1 ‘loss3-classifier’ Fully Connected 1000 fully connected layer
2 ‘prob’ Softmax softmax
3 ‘output’ Classification Output crossentropyex with ‘tench’ and 999 other classes
I don’t need to replace Softmax layer.
Please help me creating the function of findLayersToReplace.
Thank you very much
Hana Razak Hello,
I’m trying the deep learning using googlenet and I don’t know how to solve the ‘findLayersToReplace’.
I tried this code but it give 3 layers instead of 2 layers that need to find.
layers = net.Layers(end-2:end);
layers =
3×1 Layer array with layers:
1 ‘loss3-classifier’ Fully Connected 1000 fully connected layer
2 ‘prob’ Softmax softmax
3 ‘output’ Classification Output crossentropyex with ‘tench’ and 999 other classes
I don’t need to replace Softmax layer.
Please help me creating the function of findLayersToReplace.
Thank you very much
Hana Razak deep-learning, googlenet, layers MATLAB Answers — New Questions
merging/uniting plots having multiple data
Hello,
I have 5 figures, and i need to merge them, the resulting fig must be from 2.2 to 30 GHz in axis, and in the y axis, the data must follow the previous one.
How can I do this with a code?
I wanted to copy them to excel in single columns, and plot at once. However excel does not accept the data due to a cell error in copy paste, so I need to do it in code. And may be a little smoothing of smooth(data,0.02).
Any help would be appreciated.Hello,
I have 5 figures, and i need to merge them, the resulting fig must be from 2.2 to 30 GHz in axis, and in the y axis, the data must follow the previous one.
How can I do this with a code?
I wanted to copy them to excel in single columns, and plot at once. However excel does not accept the data due to a cell error in copy paste, so I need to do it in code. And may be a little smoothing of smooth(data,0.02).
Any help would be appreciated. Hello,
I have 5 figures, and i need to merge them, the resulting fig must be from 2.2 to 30 GHz in axis, and in the y axis, the data must follow the previous one.
How can I do this with a code?
I wanted to copy them to excel in single columns, and plot at once. However excel does not accept the data due to a cell error in copy paste, so I need to do it in code. And may be a little smoothing of smooth(data,0.02).
Any help would be appreciated. merging plots, unite figs MATLAB Answers — New Questions
Encoding conditional assignments in SimBiology
Is it possible to define conditional assignments in SimBiology, i.e.
if a > 0
param1 = a + b
else
param1 = a + c
end
I am aware of events but it is insuffient as it lacks the ‘else’ expression.Is it possible to define conditional assignments in SimBiology, i.e.
if a > 0
param1 = a + b
else
param1 = a + c
end
I am aware of events but it is insuffient as it lacks the ‘else’ expression. Is it possible to define conditional assignments in SimBiology, i.e.
if a > 0
param1 = a + b
else
param1 = a + c
end
I am aware of events but it is insuffient as it lacks the ‘else’ expression. conditional, assignment MATLAB Answers — New Questions
Genetic Algorithm with a graph
function C = Myfunm(x)
C = – (14.9*100)/(x(1)^2-11.9723*x(1)+70.0051+10*cos((pi*x(1))/2)+8*sin(5*pi*x(1))-(exp(-((x(2)-0.5)^2)/2))/sqrt(5));
I solved this problem with the Genetic Algorithm and i want to present the graph which depicts the max solution depending on the number of generations. I don’t know how to plot the graph. Is there a certain tool or do i have to write a new code?function C = Myfunm(x)
C = – (14.9*100)/(x(1)^2-11.9723*x(1)+70.0051+10*cos((pi*x(1))/2)+8*sin(5*pi*x(1))-(exp(-((x(2)-0.5)^2)/2))/sqrt(5));
I solved this problem with the Genetic Algorithm and i want to present the graph which depicts the max solution depending on the number of generations. I don’t know how to plot the graph. Is there a certain tool or do i have to write a new code? function C = Myfunm(x)
C = – (14.9*100)/(x(1)^2-11.9723*x(1)+70.0051+10*cos((pi*x(1))/2)+8*sin(5*pi*x(1))-(exp(-((x(2)-0.5)^2)/2))/sqrt(5));
I solved this problem with the Genetic Algorithm and i want to present the graph which depicts the max solution depending on the number of generations. I don’t know how to plot the graph. Is there a certain tool or do i have to write a new code? maximazitaion, genetic algorithm MATLAB Answers — New Questions
how to perform matrix multiplication of a 4×4 and 4×11 matrices in simulink?
having trouble preforming a matrix multiplicationhaving trouble preforming a matrix multiplication having trouble preforming a matrix multiplication matrix multiplication MATLAB Answers — New Questions
How to convert from a function of frames to a function of time for radar board (Infineon Position2Go)?
Hi Matlab Community,
I am currently using Infineon’s Position2Go FMCW radar board for my project to measure instantaneous sprinting speed and walking speed. After extracting the raw data to Matlab, I noticed that the graphs I have are all as a function of Frames on the X axis. How can I convert them to a function of time (in seconds) instead?
My configs are as follows:
32 Chirps Per Frame
64 Samples Per Chirp
150ms Frame Interval
Does it mean that for every second, there are 6.66 Frames(1/150ms) ?Hi Matlab Community,
I am currently using Infineon’s Position2Go FMCW radar board for my project to measure instantaneous sprinting speed and walking speed. After extracting the raw data to Matlab, I noticed that the graphs I have are all as a function of Frames on the X axis. How can I convert them to a function of time (in seconds) instead?
My configs are as follows:
32 Chirps Per Frame
64 Samples Per Chirp
150ms Frame Interval
Does it mean that for every second, there are 6.66 Frames(1/150ms) ? Hi Matlab Community,
I am currently using Infineon’s Position2Go FMCW radar board for my project to measure instantaneous sprinting speed and walking speed. After extracting the raw data to Matlab, I noticed that the graphs I have are all as a function of Frames on the X axis. How can I convert them to a function of time (in seconds) instead?
My configs are as follows:
32 Chirps Per Frame
64 Samples Per Chirp
150ms Frame Interval
Does it mean that for every second, there are 6.66 Frames(1/150ms) ? infineon position2go frames seconds MATLAB Answers — New Questions
App running slowly after some time
I have an app that I built in MATLAB, a rather complex app with many complex features. I noticed that over time, the app becomes laggy and slow, with every graphical action taking more time than before. Is there a solution to this? or at least a way to understand why this happens?
many thanks
NathanI have an app that I built in MATLAB, a rather complex app with many complex features. I noticed that over time, the app becomes laggy and slow, with every graphical action taking more time than before. Is there a solution to this? or at least a way to understand why this happens?
many thanks
Nathan I have an app that I built in MATLAB, a rather complex app with many complex features. I noticed that over time, the app becomes laggy and slow, with every graphical action taking more time than before. Is there a solution to this? or at least a way to understand why this happens?
many thanks
Nathan app designer, appdesigner, lags, slow MATLAB Answers — New Questions
How to write StateFcn in Nonlinear MPC Controller
Nowdays, I am doing some works about visual servoing. But there are some troubles with the nonlinear MPC Controller. I have read the example named ‘Control Quadruple-Tank Using Passivity-Based Nonlinear MPC’. There is a code nlobj.Model.StateFcn = "stateFcnQuadrupleTank".
I opened it, and the content shows as a picture as follows. It looks like the example uses code to express the dynamic system. I want to know if I can use a Simulink model, which is already done, to replace the code.
Thank a lot for your help!Nowdays, I am doing some works about visual servoing. But there are some troubles with the nonlinear MPC Controller. I have read the example named ‘Control Quadruple-Tank Using Passivity-Based Nonlinear MPC’. There is a code nlobj.Model.StateFcn = "stateFcnQuadrupleTank".
I opened it, and the content shows as a picture as follows. It looks like the example uses code to express the dynamic system. I want to know if I can use a Simulink model, which is already done, to replace the code.
Thank a lot for your help! Nowdays, I am doing some works about visual servoing. But there are some troubles with the nonlinear MPC Controller. I have read the example named ‘Control Quadruple-Tank Using Passivity-Based Nonlinear MPC’. There is a code nlobj.Model.StateFcn = "stateFcnQuadrupleTank".
I opened it, and the content shows as a picture as follows. It looks like the example uses code to express the dynamic system. I want to know if I can use a Simulink model, which is already done, to replace the code.
Thank a lot for your help! mpc, ibvs MATLAB Answers — New Questions
Is this a correct way to use fsolve?
Since fsolve keeps giving me answers with a very small but non-zero imaginary part, which i really don’t want, I though about giving the derivative of my function. Is this a correct way to do it? Also, is there a way to tell the function not to go outside the reale line?
%g is a function that is defined by an equation. I know that is invertible
%and takes values between 0 and kappa.
function g = g(y, z, p, kappa, beta, mu, muz, sigma, sigmaz)
K = (mu^2/sigma^2)*0.5;
M = (sigmaz*mu)/sigma;
q = 1/(p-1);
alpha = (sqrt((beta-M-K)^2+4*K*(beta-muz))-beta+M+K)/(2*K);
C = beta-K*p/(1-p);
%function whose zero i need to find (with respect to w)
F = @(w) ((1-p)/C)*(kappa^q – w^q)+y+z-z*(w/kappa)^(alpha-1);
%its derivative with respect to w
J = @(w) ((1-p)/C)*(-q*(w^(q-1))) -z*((alpha-1)*w^(alpha-2))/(kappa^(alpha-1));
options = optimoptions(‘fsolve’, ‘SpecifyObjectiveGradient’, true);
fun = {F, J};
w0 = kappa/2;
g = fsolve(fun, w0, options);
endSince fsolve keeps giving me answers with a very small but non-zero imaginary part, which i really don’t want, I though about giving the derivative of my function. Is this a correct way to do it? Also, is there a way to tell the function not to go outside the reale line?
%g is a function that is defined by an equation. I know that is invertible
%and takes values between 0 and kappa.
function g = g(y, z, p, kappa, beta, mu, muz, sigma, sigmaz)
K = (mu^2/sigma^2)*0.5;
M = (sigmaz*mu)/sigma;
q = 1/(p-1);
alpha = (sqrt((beta-M-K)^2+4*K*(beta-muz))-beta+M+K)/(2*K);
C = beta-K*p/(1-p);
%function whose zero i need to find (with respect to w)
F = @(w) ((1-p)/C)*(kappa^q – w^q)+y+z-z*(w/kappa)^(alpha-1);
%its derivative with respect to w
J = @(w) ((1-p)/C)*(-q*(w^(q-1))) -z*((alpha-1)*w^(alpha-2))/(kappa^(alpha-1));
options = optimoptions(‘fsolve’, ‘SpecifyObjectiveGradient’, true);
fun = {F, J};
w0 = kappa/2;
g = fsolve(fun, w0, options);
end Since fsolve keeps giving me answers with a very small but non-zero imaginary part, which i really don’t want, I though about giving the derivative of my function. Is this a correct way to do it? Also, is there a way to tell the function not to go outside the reale line?
%g is a function that is defined by an equation. I know that is invertible
%and takes values between 0 and kappa.
function g = g(y, z, p, kappa, beta, mu, muz, sigma, sigmaz)
K = (mu^2/sigma^2)*0.5;
M = (sigmaz*mu)/sigma;
q = 1/(p-1);
alpha = (sqrt((beta-M-K)^2+4*K*(beta-muz))-beta+M+K)/(2*K);
C = beta-K*p/(1-p);
%function whose zero i need to find (with respect to w)
F = @(w) ((1-p)/C)*(kappa^q – w^q)+y+z-z*(w/kappa)^(alpha-1);
%its derivative with respect to w
J = @(w) ((1-p)/C)*(-q*(w^(q-1))) -z*((alpha-1)*w^(alpha-2))/(kappa^(alpha-1));
options = optimoptions(‘fsolve’, ‘SpecifyObjectiveGradient’, true);
fun = {F, J};
w0 = kappa/2;
g = fsolve(fun, w0, options);
end fsolve, complex values, jacobian MATLAB Answers — New Questions