Category: Matlab
Category Archives: Matlab
how to run .mlapp with Runtime?
Hi,
I have an .mlapp file, and would like to run using RunTime only.
What should I do?Hi,
I have an .mlapp file, and would like to run using RunTime only.
What should I do? Hi,
I have an .mlapp file, and would like to run using RunTime only.
What should I do? .mlapp MATLAB Answers — New Questions
Extracting Data from Figures and Vectors
Dear all,
I have the following code in which I want to extracxt y values (displacements) for 12ft, 24ft and 36ft along a 48ft beam.
clear, clc, close all
EI = 29000*13400; % Flexural rigidity
L = 48; % Length of Beam
P = 1; % Loading
R1y = 0.75; % Support reaction at support 1
R2y = 0.25; % Support reaction at support 2
x1 = 0:0.1:12; % X values for 0 < x < 12
dx1 = x1(2) – x1(1); % Step size
x2 = 12:0.1:48; % X values for 0 < x < 12
Mx1 = R1y*x1/(EI); % Moment function for x1
dx2 = x2(2) – x2(1); % Step size
Mx2 = (R1y*x2 – P*(x2-12))/(EI); % Moment function for x2
y1(1) = 0; % Initial condition for y1
b = 36;
z1(1) = P*b*(L^2 – b^2)/(6*L*EI); % Initial condition for z1 (slope)
% Compute displacement for 0 < x1 < 12
for i = 1:length(x1)-1
y1(i+1) = y1(i) + z1(i)*dx1;
z1(i+1) = z1(i) – Mx1(i)*dx1;
end
y2(1) = y1(end) % Initial condition for y2
z2(1) = z1(end) % Initial condition for z2 (slope)
% Compute displacement for 12 < x2 < 48
for i = 1:length(x2)-1
y2(i+1) = y2(i) + z2(i)*dx2;
z2(i+1) = z2(i) – Mx2(i)*dx2;
end
% Plot results
plot(x1,y1,x2,y2)
grid on
My y1 vector is 121 interations long and my y2 vector is 361 iterations long. How do I extract from the data the values at 12ft, 24ft and 36ft of the beam in the most efficient way? If for example I put y1(12) I do not get the value at 12ft along the 48ft beam, because I have made a step size 0.1 and not 1.
Many thanks in advance,
ScottDear all,
I have the following code in which I want to extracxt y values (displacements) for 12ft, 24ft and 36ft along a 48ft beam.
clear, clc, close all
EI = 29000*13400; % Flexural rigidity
L = 48; % Length of Beam
P = 1; % Loading
R1y = 0.75; % Support reaction at support 1
R2y = 0.25; % Support reaction at support 2
x1 = 0:0.1:12; % X values for 0 < x < 12
dx1 = x1(2) – x1(1); % Step size
x2 = 12:0.1:48; % X values for 0 < x < 12
Mx1 = R1y*x1/(EI); % Moment function for x1
dx2 = x2(2) – x2(1); % Step size
Mx2 = (R1y*x2 – P*(x2-12))/(EI); % Moment function for x2
y1(1) = 0; % Initial condition for y1
b = 36;
z1(1) = P*b*(L^2 – b^2)/(6*L*EI); % Initial condition for z1 (slope)
% Compute displacement for 0 < x1 < 12
for i = 1:length(x1)-1
y1(i+1) = y1(i) + z1(i)*dx1;
z1(i+1) = z1(i) – Mx1(i)*dx1;
end
y2(1) = y1(end) % Initial condition for y2
z2(1) = z1(end) % Initial condition for z2 (slope)
% Compute displacement for 12 < x2 < 48
for i = 1:length(x2)-1
y2(i+1) = y2(i) + z2(i)*dx2;
z2(i+1) = z2(i) – Mx2(i)*dx2;
end
% Plot results
plot(x1,y1,x2,y2)
grid on
My y1 vector is 121 interations long and my y2 vector is 361 iterations long. How do I extract from the data the values at 12ft, 24ft and 36ft of the beam in the most efficient way? If for example I put y1(12) I do not get the value at 12ft along the 48ft beam, because I have made a step size 0.1 and not 1.
Many thanks in advance,
Scott Dear all,
I have the following code in which I want to extracxt y values (displacements) for 12ft, 24ft and 36ft along a 48ft beam.
clear, clc, close all
EI = 29000*13400; % Flexural rigidity
L = 48; % Length of Beam
P = 1; % Loading
R1y = 0.75; % Support reaction at support 1
R2y = 0.25; % Support reaction at support 2
x1 = 0:0.1:12; % X values for 0 < x < 12
dx1 = x1(2) – x1(1); % Step size
x2 = 12:0.1:48; % X values for 0 < x < 12
Mx1 = R1y*x1/(EI); % Moment function for x1
dx2 = x2(2) – x2(1); % Step size
Mx2 = (R1y*x2 – P*(x2-12))/(EI); % Moment function for x2
y1(1) = 0; % Initial condition for y1
b = 36;
z1(1) = P*b*(L^2 – b^2)/(6*L*EI); % Initial condition for z1 (slope)
% Compute displacement for 0 < x1 < 12
for i = 1:length(x1)-1
y1(i+1) = y1(i) + z1(i)*dx1;
z1(i+1) = z1(i) – Mx1(i)*dx1;
end
y2(1) = y1(end) % Initial condition for y2
z2(1) = z1(end) % Initial condition for z2 (slope)
% Compute displacement for 12 < x2 < 48
for i = 1:length(x2)-1
y2(i+1) = y2(i) + z2(i)*dx2;
z2(i+1) = z2(i) – Mx2(i)*dx2;
end
% Plot results
plot(x1,y1,x2,y2)
grid on
My y1 vector is 121 interations long and my y2 vector is 361 iterations long. How do I extract from the data the values at 12ft, 24ft and 36ft of the beam in the most efficient way? If for example I put y1(12) I do not get the value at 12ft along the 48ft beam, because I have made a step size 0.1 and not 1.
Many thanks in advance,
Scott figures, for loop, vectors MATLAB Answers — New Questions
How to input “Eb/No vector” to AWGN block in simulink?
I am using AWGN in my simulink model where "AWGN block" is being used. Inside AWGN block, there is option for Eb/No. I need to input a vector for Eb/No instead of a single value. How to do this? Can I input this vector from workspace?I am using AWGN in my simulink model where "AWGN block" is being used. Inside AWGN block, there is option for Eb/No. I need to input a vector for Eb/No instead of a single value. How to do this? Can I input this vector from workspace? I am using AWGN in my simulink model where "AWGN block" is being used. Inside AWGN block, there is option for Eb/No. I need to input a vector for Eb/No instead of a single value. How to do this? Can I input this vector from workspace? awgn, simulink, eb/no, input from workspace MATLAB Answers — New Questions
Electric Vehicle Routing Problem
I am doing a project on electric vehicle routing problem where the vehicle has multi destinations and also to consider the charging stations locations, i need support in what optimization techniques that can be used and from where i could code it effiecntly. I found the travel salesman techniques and ant-colony but i don’t know if this what i need. I also need to visualize the process so any resources, thesis or helpful guides would be really apreciated.I am doing a project on electric vehicle routing problem where the vehicle has multi destinations and also to consider the charging stations locations, i need support in what optimization techniques that can be used and from where i could code it effiecntly. I found the travel salesman techniques and ant-colony but i don’t know if this what i need. I also need to visualize the process so any resources, thesis or helpful guides would be really apreciated. I am doing a project on electric vehicle routing problem where the vehicle has multi destinations and also to consider the charging stations locations, i need support in what optimization techniques that can be used and from where i could code it effiecntly. I found the travel salesman techniques and ant-colony but i don’t know if this what i need. I also need to visualize the process so any resources, thesis or helpful guides would be really apreciated. electric vehicle, routing problem, optimization MATLAB Answers — New Questions
Problem with Building tmc-file / tmx-file from Simulink Model to load into Twincat 3
After i installed the TE14xx Toolbox from Beckhoff, to compile a C++ – Code to represent my Simulink Model in Twincat3, i receive the following error Message.
All components that are required are installed. VS2019, test mode within Windows for signing the certificates and the drivers and of course the certificate that has been created. It looks like I am missing a toolset for compiling. What strange is that along with VS2019 I also have the latest MSVC v142 buildtools.
I think it is a very easy solution for this, but i cannot see it.
Is their a point where i have to link the compiler to matlab?
Warning: No appropriate platform toolset was found
ERROR: Unable to find compatible C++ platform toolset version.
ERROR: Can’t create log file "C"
### Starting build procedure for: AnBeckhoff
################################################################################
### Starting TwinCAT TE1400 Simulink Model Verification
### Model Name: AnBeckhoff
### MATLAB Version: R2021b (win64)
### TE1400 Version: 2.3.1.1
################################################################################
################################################################################
### Generating code and artifacts to ‘Model specific’ folder structure
### Generating code into build folder: C:testAnBeckhoff_tcgrt
### Invoking Target Language Compiler on AnBeckhoff.rtw
### Using System Target File: C:TwinCATFunctionsTE14xx-ToolsForMatlabAndSimulinkTE140xSimulinkTLCTwinCatGrt.tlc
### Loading TLC function libraries
### Initial pass through model to cache user defined code
### Caching model source code
### Writing header file AnBeckhoff_types.h
### Writing header file AnBeckhoff.h
### Writing header file rtwtypes.h
### Writing header file multiword_types.h
### Writing source file AnBeckhoff.cpp
### Writing header file AnBeckhoff_private.h
### Writing header file rtmodel.h
.
### Writing source file AnBeckhoff_data.cpp
### Writing header file rt_nonfinite.h
### Writing source file rt_nonfinite.cpp
### Writing header file rtGetInf.h
### Writing source file rtGetInf.cpp
### Writing header file rtGetNaN.h
.
### Writing source file rtGetNaN.cpp
### TLC code generation complete.
….### Creating HTML report file index.html
### Saving binary information cache.
.
### Processing Template Makefile: C:TwinCATFunctionsTE14xx-ToolsForMatlabAndSimulinkTE140xSimulinkTLCtcgrt_msbuild.tmf
### Makefile C:testAnBeckhoff_tcgrtAnBeckhoff.mk is up to date
################################################################################
### Starting TwinCAT TE1400 Simulink Model Export
################################################################################
Warning: Unable to get handle of subsystem <S51>: Unable to locate Simulink Coder block or system name ‘<S51>’ in model ‘AnBeckhoff’
Model hierarchy export finished successfully
Warning: No appropriate platform toolset was found
ERROR: Unable to find compatible C++ platform toolset version.
ERROR: Can’t create log file "C"
[Info]
[Info#ModuleGenerator]
ProductId: TE140x
ProductName: TE140x-TargetForMatlabSimulink
Version: 2.3.1.1
InstallDir: C:TwinCATFunctionsTE14xx-ToolsForMatlabAndSimulinkTE140x
SDK: C:TwinCATFunctionsTE14xx-ToolsForMatlabAndSimulinkTE140xSDK
[Info#ModuleGeneratorHost]
Description: MATLAB 9.11.0.1837725 (R2021b) Update 2 (win64)
InstallDir: C:Program FilesMATLABR2021b
[Info#TE140x]
SDK: C:TwinCATFunctionsTE14xx-ToolsForMatlabAndSimulinkTE140xSDK
[Create Project]
[Export Classes]
[Export Classes#License]
[License#AnBeckhoff]
Warning: ExportAnBeckhoff
[Generate#AnBeckhoff#TcCom]
Implement interfaces
### Build procedure for AnBeckhoff aborted due to an error.
Build Summary
Top model targets built:
Model Action Rebuild Reason
======================================================================
AnBeckhoff Failed Code generation information file does not exist.
0 of 1 models built (0 models already up to date)
Build duration: 0h 0m 14.445s
The call to TwinCatGrt_make_rtw_hook, during the after_make hook generated the following error:
Project preparation failed
The build process will terminate as a result.
Caused by: Project preparation failedAfter i installed the TE14xx Toolbox from Beckhoff, to compile a C++ – Code to represent my Simulink Model in Twincat3, i receive the following error Message.
All components that are required are installed. VS2019, test mode within Windows for signing the certificates and the drivers and of course the certificate that has been created. It looks like I am missing a toolset for compiling. What strange is that along with VS2019 I also have the latest MSVC v142 buildtools.
I think it is a very easy solution for this, but i cannot see it.
Is their a point where i have to link the compiler to matlab?
Warning: No appropriate platform toolset was found
ERROR: Unable to find compatible C++ platform toolset version.
ERROR: Can’t create log file "C"
### Starting build procedure for: AnBeckhoff
################################################################################
### Starting TwinCAT TE1400 Simulink Model Verification
### Model Name: AnBeckhoff
### MATLAB Version: R2021b (win64)
### TE1400 Version: 2.3.1.1
################################################################################
################################################################################
### Generating code and artifacts to ‘Model specific’ folder structure
### Generating code into build folder: C:testAnBeckhoff_tcgrt
### Invoking Target Language Compiler on AnBeckhoff.rtw
### Using System Target File: C:TwinCATFunctionsTE14xx-ToolsForMatlabAndSimulinkTE140xSimulinkTLCTwinCatGrt.tlc
### Loading TLC function libraries
### Initial pass through model to cache user defined code
### Caching model source code
### Writing header file AnBeckhoff_types.h
### Writing header file AnBeckhoff.h
### Writing header file rtwtypes.h
### Writing header file multiword_types.h
### Writing source file AnBeckhoff.cpp
### Writing header file AnBeckhoff_private.h
### Writing header file rtmodel.h
.
### Writing source file AnBeckhoff_data.cpp
### Writing header file rt_nonfinite.h
### Writing source file rt_nonfinite.cpp
### Writing header file rtGetInf.h
### Writing source file rtGetInf.cpp
### Writing header file rtGetNaN.h
.
### Writing source file rtGetNaN.cpp
### TLC code generation complete.
….### Creating HTML report file index.html
### Saving binary information cache.
.
### Processing Template Makefile: C:TwinCATFunctionsTE14xx-ToolsForMatlabAndSimulinkTE140xSimulinkTLCtcgrt_msbuild.tmf
### Makefile C:testAnBeckhoff_tcgrtAnBeckhoff.mk is up to date
################################################################################
### Starting TwinCAT TE1400 Simulink Model Export
################################################################################
Warning: Unable to get handle of subsystem <S51>: Unable to locate Simulink Coder block or system name ‘<S51>’ in model ‘AnBeckhoff’
Model hierarchy export finished successfully
Warning: No appropriate platform toolset was found
ERROR: Unable to find compatible C++ platform toolset version.
ERROR: Can’t create log file "C"
[Info]
[Info#ModuleGenerator]
ProductId: TE140x
ProductName: TE140x-TargetForMatlabSimulink
Version: 2.3.1.1
InstallDir: C:TwinCATFunctionsTE14xx-ToolsForMatlabAndSimulinkTE140x
SDK: C:TwinCATFunctionsTE14xx-ToolsForMatlabAndSimulinkTE140xSDK
[Info#ModuleGeneratorHost]
Description: MATLAB 9.11.0.1837725 (R2021b) Update 2 (win64)
InstallDir: C:Program FilesMATLABR2021b
[Info#TE140x]
SDK: C:TwinCATFunctionsTE14xx-ToolsForMatlabAndSimulinkTE140xSDK
[Create Project]
[Export Classes]
[Export Classes#License]
[License#AnBeckhoff]
Warning: ExportAnBeckhoff
[Generate#AnBeckhoff#TcCom]
Implement interfaces
### Build procedure for AnBeckhoff aborted due to an error.
Build Summary
Top model targets built:
Model Action Rebuild Reason
======================================================================
AnBeckhoff Failed Code generation information file does not exist.
0 of 1 models built (0 models already up to date)
Build duration: 0h 0m 14.445s
The call to TwinCatGrt_make_rtw_hook, during the after_make hook generated the following error:
Project preparation failed
The build process will terminate as a result.
Caused by: Project preparation failed After i installed the TE14xx Toolbox from Beckhoff, to compile a C++ – Code to represent my Simulink Model in Twincat3, i receive the following error Message.
All components that are required are installed. VS2019, test mode within Windows for signing the certificates and the drivers and of course the certificate that has been created. It looks like I am missing a toolset for compiling. What strange is that along with VS2019 I also have the latest MSVC v142 buildtools.
I think it is a very easy solution for this, but i cannot see it.
Is their a point where i have to link the compiler to matlab?
Warning: No appropriate platform toolset was found
ERROR: Unable to find compatible C++ platform toolset version.
ERROR: Can’t create log file "C"
### Starting build procedure for: AnBeckhoff
################################################################################
### Starting TwinCAT TE1400 Simulink Model Verification
### Model Name: AnBeckhoff
### MATLAB Version: R2021b (win64)
### TE1400 Version: 2.3.1.1
################################################################################
################################################################################
### Generating code and artifacts to ‘Model specific’ folder structure
### Generating code into build folder: C:testAnBeckhoff_tcgrt
### Invoking Target Language Compiler on AnBeckhoff.rtw
### Using System Target File: C:TwinCATFunctionsTE14xx-ToolsForMatlabAndSimulinkTE140xSimulinkTLCTwinCatGrt.tlc
### Loading TLC function libraries
### Initial pass through model to cache user defined code
### Caching model source code
### Writing header file AnBeckhoff_types.h
### Writing header file AnBeckhoff.h
### Writing header file rtwtypes.h
### Writing header file multiword_types.h
### Writing source file AnBeckhoff.cpp
### Writing header file AnBeckhoff_private.h
### Writing header file rtmodel.h
.
### Writing source file AnBeckhoff_data.cpp
### Writing header file rt_nonfinite.h
### Writing source file rt_nonfinite.cpp
### Writing header file rtGetInf.h
### Writing source file rtGetInf.cpp
### Writing header file rtGetNaN.h
.
### Writing source file rtGetNaN.cpp
### TLC code generation complete.
….### Creating HTML report file index.html
### Saving binary information cache.
.
### Processing Template Makefile: C:TwinCATFunctionsTE14xx-ToolsForMatlabAndSimulinkTE140xSimulinkTLCtcgrt_msbuild.tmf
### Makefile C:testAnBeckhoff_tcgrtAnBeckhoff.mk is up to date
################################################################################
### Starting TwinCAT TE1400 Simulink Model Export
################################################################################
Warning: Unable to get handle of subsystem <S51>: Unable to locate Simulink Coder block or system name ‘<S51>’ in model ‘AnBeckhoff’
Model hierarchy export finished successfully
Warning: No appropriate platform toolset was found
ERROR: Unable to find compatible C++ platform toolset version.
ERROR: Can’t create log file "C"
[Info]
[Info#ModuleGenerator]
ProductId: TE140x
ProductName: TE140x-TargetForMatlabSimulink
Version: 2.3.1.1
InstallDir: C:TwinCATFunctionsTE14xx-ToolsForMatlabAndSimulinkTE140x
SDK: C:TwinCATFunctionsTE14xx-ToolsForMatlabAndSimulinkTE140xSDK
[Info#ModuleGeneratorHost]
Description: MATLAB 9.11.0.1837725 (R2021b) Update 2 (win64)
InstallDir: C:Program FilesMATLABR2021b
[Info#TE140x]
SDK: C:TwinCATFunctionsTE14xx-ToolsForMatlabAndSimulinkTE140xSDK
[Create Project]
[Export Classes]
[Export Classes#License]
[License#AnBeckhoff]
Warning: ExportAnBeckhoff
[Generate#AnBeckhoff#TcCom]
Implement interfaces
### Build procedure for AnBeckhoff aborted due to an error.
Build Summary
Top model targets built:
Model Action Rebuild Reason
======================================================================
AnBeckhoff Failed Code generation information file does not exist.
0 of 1 models built (0 models already up to date)
Build duration: 0h 0m 14.445s
The call to TwinCatGrt_make_rtw_hook, during the after_make hook generated the following error:
Project preparation failed
The build process will terminate as a result.
Caused by: Project preparation failed twincat, matlab, simulink, build, c++, tlc, simulation, programming, signal processing, matlab compiler, ode, embedded coder, matlab coder, simulink coder MATLAB Answers — New Questions
“From” block within Model reference block with global visibility
I have a the source of the signal on the most-top simulink structure marked with Goto with global tag visibility
but this signal is not visible from within Model Referance system …
Is this an issue or expected behaviour?
How to access global signal "Goto" from "From" inside Model reference system?I have a the source of the signal on the most-top simulink structure marked with Goto with global tag visibility
but this signal is not visible from within Model Referance system …
Is this an issue or expected behaviour?
How to access global signal "Goto" from "From" inside Model reference system? I have a the source of the signal on the most-top simulink structure marked with Goto with global tag visibility
but this signal is not visible from within Model Referance system …
Is this an issue or expected behaviour?
How to access global signal "Goto" from "From" inside Model reference system? goto global visibiltiy MATLAB Answers — New Questions
C# application crashes while using Matlab DotNetLibrary
I have created dll library (.Net Assembly) of my matlab functions which I use in C# WinForm app. Now I am facing issue that most of the times my C# app crashes with code 3221226356 (0xc0000374), but sometimes it runs without issue as well.
I checked Event Viewer and got this info:
Faulting application name: Search.exe, version: 1.0.0.0, time stamp: 0xa6ac8f38
Faulting module name: ntdll.dll, version: 10.0.22621.3235, time stamp: 0xa2c4352c
Exception code: 0xc0000374
Fault offset: 0x000000000010c1a9
Faulting process id: 0x0x4CE0
Faulting application start time: 0x0x1DA74D3C58BCC79
Faulting application path: C:UserspathSearch.exe
Faulting module path: C:WINDOWSSYSTEM32ntdll.dll
Report Id: 5a6729dd-9f7c-447e-9e75-adc2628f929b
Faulting package full name:
Faulting package-relative application ID:
I also created a crash dump and got this info:
——————————————————————————–
std::terminate() detected at 2024-03-13 04:14:38 +0500
——————————————————————————–
Configuration:
Crash Decoding : Disabled – No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : windows-1252
Deployed : true
Graphics Driver : Unknown hardware
Graphics card 1 : Intel Corporation ( 0x8086 ) Intel(R) UHD Graphics Version 31.0.101.4502 (2023-7-13)
Java Version : Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
MATLAB Architecture : win64
MATLAB Entitlement ID : Unknown
MATLAB Root : C:Program FilesPolyspaceR2021a
MATLAB Version : 9.10.0.1602886 (R2021a)
OpenGL : hardware
Operating System : Microsoft Windows 11 Enterprise
Process ID : 7824
Processor ID : x86 Family 6 Model 154 Stepping 4, GenuineIntel
Session Key : 8f79256f-a074-4e06-9630-7d770196d4b9
Window System : Version 10.0 (Build 22631)
Fault Count: 1
Abnormal termination:
std::terminate()
Current Thread: ‘MCR 0 interpreter thread’ id 19576
Register State (captured):
RAX = 00007fff8d43a758 RBX = 00007fff8d43a758
RCX = 00000089df9fbca0 RDX = 0000000000000000
RSP = 00000089df9fbbe0 RBP = 00000089df9fc9d0
RSI = 0000000000000000 RDI = 00007fff8d43a758
R8 = 000000000000000f R9 = 00000089df9fbb58
R10 = 0000000000000020 R11 = 00007fff8d42a750
R12 = 00000089df9fc8d8 R13 = 0000025c32cd7fe0
R14 = 00007fff8d42a698 R15 = 00000089df9fc310
RIP = 00007fff8d3110ba EFL = 00000202
CS = 0033 FS = 0053 GS = 002b
Stack Trace (captured):
[ 0] 0x00007fff8d30a063 C:Program FilesPolyspaceR2021abinwin64libmwfl.dll+00041059 foundation::core::diag::thread_context::unspecified_bool+00000051
[ 1] 0x00007fff8d307338 C:Program FilesPolyspaceR2021abinwin64libmwfl.dll+00029496 foundation::core::diag::stacktrace_base::capture+00000024
[ 2] 0x00007fff8d30cbc1 C:Program FilesPolyspaceR2021abinwin64libmwfl.dll+00052161 foundation::core::diag::symbols::getSymbolAddress+00010001
[ 3] 0x00007fff8d30fe47 C:Program FilesPolyspaceR2021abinwin64libmwfl.dll+00065095 foundation::core::diag::is_terminate_message_enabled+00000567
[ 4] 0x00007fff3aae9abd C:Program FilesPolyspaceR2021abinwin64mcr.dll+00957117 mcr::shutdown::startWatchdog+00035885
[ 5] 0x00007fff3aae92c3 C:Program FilesPolyspaceR2021abinwin64mcr.dll+00955075 mcr::shutdown::startWatchdog+00033843
[ 6] 0x00007fff3aae4b09 C:Program FilesPolyspaceR2021abinwin64mcr.dll+00936713 mcr::shutdown::startWatchdog+00015481
[ 7] 0x00007fff3aaeb173 C:Program FilesPolyspaceR2021abinwin64mcr.dll+00962931 mnSetSegvServiceUrl+00000195
[ 8] 0x00007fffa3a65004 C:Program FilesPolyspaceR2021abinwin64VCRUNTIME140.dll+00020484 purecall+00000020
[ 9] 0x00007fff3f0c9573 C:Program FilesPolyspaceR2021abinwin64mlutil.dll+03183987 cmddistributor::PackagedTaskIIP::~PackagedTaskIIP+00000051
[ 10] 0x00007fff3f0bfeb5 C:Program FilesPolyspaceR2021abinwin64mlutil.dll+03145397 cmddistributor::CmdRequestTraits<cmddistributor::FcnCmdRequest<void> >::operator=+00001797
[ 11] 0x00007fff3f0c0ffb C:Program FilesPolyspaceR2021abinwin64mlutil.dll+03149819 cmddistributor::CmdRequestTraits<cmddistributor::FcnCmdRequest<void> >::operator=+00006219
[ 12] 0x00007fff3ac6cd1f C:Program FilesPolyspaceR2021abinwin64iqm.dll+00773407 iqm::IqmPlugin<cmddistributor::PackagedTaskIIP>::~IqmPlugin<cmddistributor::PackagedTaskIIP>+00000063
[ 13] 0x00007fff3aa7c6e3 C:Program FilesPolyspaceR2021abinwin64mcr.dll+00509667 services::lmgr::exception::LicensingStartupException::~LicensingStartupException+00002691
[ 14] 0x00007fff3ac3f157 C:Program FilesPolyspaceR2021abinwin64iqm.dll+00586071 iqm::Iqm::setupIqmFcnPtrs+00076359
[ 15] 0x00007fff3ac42904 C:Program FilesPolyspaceR2021abinwin64iqm.dll+00600324 iqm::Iqm::setupIqmFcnPtrs+00090612
[ 16] 0x00007fff3ac6fbfb C:Program FilesPolyspaceR2021abinwin64iqm.dll+00785403 iqm::PackagedTaskPlugin::~PackagedTaskPlugin+00010635
[ 17] 0x00007fff3ac1836a C:Program FilesPolyspaceR2021abinwin64iqm.dll+00426858 iqm::Iqm::create+00011498
[ 18] 0x00007fff3ac17c32 C:Program FilesPolyspaceR2021abinwin64iqm.dll+00425010 iqm::Iqm::create+00009650
[ 19] 0x00007fff3aa558fc C:Program FilesPolyspaceR2021abinwin64mcr.dll+00350460 mcrInstantiationError::operator=+00010428
[ 20] 0x00007fff3aa564ac C:Program FilesPolyspaceR2021abinwin64mcr.dll+00353452 mcrInstantiationError::operator=+00013420
[ 21] 0x00007fff3aa53ac0 C:Program FilesPolyspaceR2021abinwin64mcr.dll+00342720 mcrInstantiationError::operator=+00002688
[ 22] 0x00007fff93d49b9a C:Program FilesPolyspaceR2021abinwin64mwboost_thread-vc142-mt-x64-1_72.dll+00039834 mwboost::thread::swap+00000074
[ 23] 0x00007fffae8e9363 C:WINDOWSSystem32ucrtbase.dll+00168803 recalloc+00000163
[ 24] 0x00007fffaec2257d C:WINDOWSSystem32KERNEL32.dll+00075133 BaseThreadInitThunk+00000029
[ 25] 0x00007fffb0e6aa58 C:WINDOWSSYSTEM32ntdll.dll+00371288 RtlUserThreadStart+00000040
I don’t understand or know how to interpret this and fix this issue, any help would be appreciated in resolving this crashing issue!I have created dll library (.Net Assembly) of my matlab functions which I use in C# WinForm app. Now I am facing issue that most of the times my C# app crashes with code 3221226356 (0xc0000374), but sometimes it runs without issue as well.
I checked Event Viewer and got this info:
Faulting application name: Search.exe, version: 1.0.0.0, time stamp: 0xa6ac8f38
Faulting module name: ntdll.dll, version: 10.0.22621.3235, time stamp: 0xa2c4352c
Exception code: 0xc0000374
Fault offset: 0x000000000010c1a9
Faulting process id: 0x0x4CE0
Faulting application start time: 0x0x1DA74D3C58BCC79
Faulting application path: C:UserspathSearch.exe
Faulting module path: C:WINDOWSSYSTEM32ntdll.dll
Report Id: 5a6729dd-9f7c-447e-9e75-adc2628f929b
Faulting package full name:
Faulting package-relative application ID:
I also created a crash dump and got this info:
——————————————————————————–
std::terminate() detected at 2024-03-13 04:14:38 +0500
——————————————————————————–
Configuration:
Crash Decoding : Disabled – No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : windows-1252
Deployed : true
Graphics Driver : Unknown hardware
Graphics card 1 : Intel Corporation ( 0x8086 ) Intel(R) UHD Graphics Version 31.0.101.4502 (2023-7-13)
Java Version : Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
MATLAB Architecture : win64
MATLAB Entitlement ID : Unknown
MATLAB Root : C:Program FilesPolyspaceR2021a
MATLAB Version : 9.10.0.1602886 (R2021a)
OpenGL : hardware
Operating System : Microsoft Windows 11 Enterprise
Process ID : 7824
Processor ID : x86 Family 6 Model 154 Stepping 4, GenuineIntel
Session Key : 8f79256f-a074-4e06-9630-7d770196d4b9
Window System : Version 10.0 (Build 22631)
Fault Count: 1
Abnormal termination:
std::terminate()
Current Thread: ‘MCR 0 interpreter thread’ id 19576
Register State (captured):
RAX = 00007fff8d43a758 RBX = 00007fff8d43a758
RCX = 00000089df9fbca0 RDX = 0000000000000000
RSP = 00000089df9fbbe0 RBP = 00000089df9fc9d0
RSI = 0000000000000000 RDI = 00007fff8d43a758
R8 = 000000000000000f R9 = 00000089df9fbb58
R10 = 0000000000000020 R11 = 00007fff8d42a750
R12 = 00000089df9fc8d8 R13 = 0000025c32cd7fe0
R14 = 00007fff8d42a698 R15 = 00000089df9fc310
RIP = 00007fff8d3110ba EFL = 00000202
CS = 0033 FS = 0053 GS = 002b
Stack Trace (captured):
[ 0] 0x00007fff8d30a063 C:Program FilesPolyspaceR2021abinwin64libmwfl.dll+00041059 foundation::core::diag::thread_context::unspecified_bool+00000051
[ 1] 0x00007fff8d307338 C:Program FilesPolyspaceR2021abinwin64libmwfl.dll+00029496 foundation::core::diag::stacktrace_base::capture+00000024
[ 2] 0x00007fff8d30cbc1 C:Program FilesPolyspaceR2021abinwin64libmwfl.dll+00052161 foundation::core::diag::symbols::getSymbolAddress+00010001
[ 3] 0x00007fff8d30fe47 C:Program FilesPolyspaceR2021abinwin64libmwfl.dll+00065095 foundation::core::diag::is_terminate_message_enabled+00000567
[ 4] 0x00007fff3aae9abd C:Program FilesPolyspaceR2021abinwin64mcr.dll+00957117 mcr::shutdown::startWatchdog+00035885
[ 5] 0x00007fff3aae92c3 C:Program FilesPolyspaceR2021abinwin64mcr.dll+00955075 mcr::shutdown::startWatchdog+00033843
[ 6] 0x00007fff3aae4b09 C:Program FilesPolyspaceR2021abinwin64mcr.dll+00936713 mcr::shutdown::startWatchdog+00015481
[ 7] 0x00007fff3aaeb173 C:Program FilesPolyspaceR2021abinwin64mcr.dll+00962931 mnSetSegvServiceUrl+00000195
[ 8] 0x00007fffa3a65004 C:Program FilesPolyspaceR2021abinwin64VCRUNTIME140.dll+00020484 purecall+00000020
[ 9] 0x00007fff3f0c9573 C:Program FilesPolyspaceR2021abinwin64mlutil.dll+03183987 cmddistributor::PackagedTaskIIP::~PackagedTaskIIP+00000051
[ 10] 0x00007fff3f0bfeb5 C:Program FilesPolyspaceR2021abinwin64mlutil.dll+03145397 cmddistributor::CmdRequestTraits<cmddistributor::FcnCmdRequest<void> >::operator=+00001797
[ 11] 0x00007fff3f0c0ffb C:Program FilesPolyspaceR2021abinwin64mlutil.dll+03149819 cmddistributor::CmdRequestTraits<cmddistributor::FcnCmdRequest<void> >::operator=+00006219
[ 12] 0x00007fff3ac6cd1f C:Program FilesPolyspaceR2021abinwin64iqm.dll+00773407 iqm::IqmPlugin<cmddistributor::PackagedTaskIIP>::~IqmPlugin<cmddistributor::PackagedTaskIIP>+00000063
[ 13] 0x00007fff3aa7c6e3 C:Program FilesPolyspaceR2021abinwin64mcr.dll+00509667 services::lmgr::exception::LicensingStartupException::~LicensingStartupException+00002691
[ 14] 0x00007fff3ac3f157 C:Program FilesPolyspaceR2021abinwin64iqm.dll+00586071 iqm::Iqm::setupIqmFcnPtrs+00076359
[ 15] 0x00007fff3ac42904 C:Program FilesPolyspaceR2021abinwin64iqm.dll+00600324 iqm::Iqm::setupIqmFcnPtrs+00090612
[ 16] 0x00007fff3ac6fbfb C:Program FilesPolyspaceR2021abinwin64iqm.dll+00785403 iqm::PackagedTaskPlugin::~PackagedTaskPlugin+00010635
[ 17] 0x00007fff3ac1836a C:Program FilesPolyspaceR2021abinwin64iqm.dll+00426858 iqm::Iqm::create+00011498
[ 18] 0x00007fff3ac17c32 C:Program FilesPolyspaceR2021abinwin64iqm.dll+00425010 iqm::Iqm::create+00009650
[ 19] 0x00007fff3aa558fc C:Program FilesPolyspaceR2021abinwin64mcr.dll+00350460 mcrInstantiationError::operator=+00010428
[ 20] 0x00007fff3aa564ac C:Program FilesPolyspaceR2021abinwin64mcr.dll+00353452 mcrInstantiationError::operator=+00013420
[ 21] 0x00007fff3aa53ac0 C:Program FilesPolyspaceR2021abinwin64mcr.dll+00342720 mcrInstantiationError::operator=+00002688
[ 22] 0x00007fff93d49b9a C:Program FilesPolyspaceR2021abinwin64mwboost_thread-vc142-mt-x64-1_72.dll+00039834 mwboost::thread::swap+00000074
[ 23] 0x00007fffae8e9363 C:WINDOWSSystem32ucrtbase.dll+00168803 recalloc+00000163
[ 24] 0x00007fffaec2257d C:WINDOWSSystem32KERNEL32.dll+00075133 BaseThreadInitThunk+00000029
[ 25] 0x00007fffb0e6aa58 C:WINDOWSSYSTEM32ntdll.dll+00371288 RtlUserThreadStart+00000040
I don’t understand or know how to interpret this and fix this issue, any help would be appreciated in resolving this crashing issue! I have created dll library (.Net Assembly) of my matlab functions which I use in C# WinForm app. Now I am facing issue that most of the times my C# app crashes with code 3221226356 (0xc0000374), but sometimes it runs without issue as well.
I checked Event Viewer and got this info:
Faulting application name: Search.exe, version: 1.0.0.0, time stamp: 0xa6ac8f38
Faulting module name: ntdll.dll, version: 10.0.22621.3235, time stamp: 0xa2c4352c
Exception code: 0xc0000374
Fault offset: 0x000000000010c1a9
Faulting process id: 0x0x4CE0
Faulting application start time: 0x0x1DA74D3C58BCC79
Faulting application path: C:UserspathSearch.exe
Faulting module path: C:WINDOWSSYSTEM32ntdll.dll
Report Id: 5a6729dd-9f7c-447e-9e75-adc2628f929b
Faulting package full name:
Faulting package-relative application ID:
I also created a crash dump and got this info:
——————————————————————————–
std::terminate() detected at 2024-03-13 04:14:38 +0500
——————————————————————————–
Configuration:
Crash Decoding : Disabled – No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : windows-1252
Deployed : true
Graphics Driver : Unknown hardware
Graphics card 1 : Intel Corporation ( 0x8086 ) Intel(R) UHD Graphics Version 31.0.101.4502 (2023-7-13)
Java Version : Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
MATLAB Architecture : win64
MATLAB Entitlement ID : Unknown
MATLAB Root : C:Program FilesPolyspaceR2021a
MATLAB Version : 9.10.0.1602886 (R2021a)
OpenGL : hardware
Operating System : Microsoft Windows 11 Enterprise
Process ID : 7824
Processor ID : x86 Family 6 Model 154 Stepping 4, GenuineIntel
Session Key : 8f79256f-a074-4e06-9630-7d770196d4b9
Window System : Version 10.0 (Build 22631)
Fault Count: 1
Abnormal termination:
std::terminate()
Current Thread: ‘MCR 0 interpreter thread’ id 19576
Register State (captured):
RAX = 00007fff8d43a758 RBX = 00007fff8d43a758
RCX = 00000089df9fbca0 RDX = 0000000000000000
RSP = 00000089df9fbbe0 RBP = 00000089df9fc9d0
RSI = 0000000000000000 RDI = 00007fff8d43a758
R8 = 000000000000000f R9 = 00000089df9fbb58
R10 = 0000000000000020 R11 = 00007fff8d42a750
R12 = 00000089df9fc8d8 R13 = 0000025c32cd7fe0
R14 = 00007fff8d42a698 R15 = 00000089df9fc310
RIP = 00007fff8d3110ba EFL = 00000202
CS = 0033 FS = 0053 GS = 002b
Stack Trace (captured):
[ 0] 0x00007fff8d30a063 C:Program FilesPolyspaceR2021abinwin64libmwfl.dll+00041059 foundation::core::diag::thread_context::unspecified_bool+00000051
[ 1] 0x00007fff8d307338 C:Program FilesPolyspaceR2021abinwin64libmwfl.dll+00029496 foundation::core::diag::stacktrace_base::capture+00000024
[ 2] 0x00007fff8d30cbc1 C:Program FilesPolyspaceR2021abinwin64libmwfl.dll+00052161 foundation::core::diag::symbols::getSymbolAddress+00010001
[ 3] 0x00007fff8d30fe47 C:Program FilesPolyspaceR2021abinwin64libmwfl.dll+00065095 foundation::core::diag::is_terminate_message_enabled+00000567
[ 4] 0x00007fff3aae9abd C:Program FilesPolyspaceR2021abinwin64mcr.dll+00957117 mcr::shutdown::startWatchdog+00035885
[ 5] 0x00007fff3aae92c3 C:Program FilesPolyspaceR2021abinwin64mcr.dll+00955075 mcr::shutdown::startWatchdog+00033843
[ 6] 0x00007fff3aae4b09 C:Program FilesPolyspaceR2021abinwin64mcr.dll+00936713 mcr::shutdown::startWatchdog+00015481
[ 7] 0x00007fff3aaeb173 C:Program FilesPolyspaceR2021abinwin64mcr.dll+00962931 mnSetSegvServiceUrl+00000195
[ 8] 0x00007fffa3a65004 C:Program FilesPolyspaceR2021abinwin64VCRUNTIME140.dll+00020484 purecall+00000020
[ 9] 0x00007fff3f0c9573 C:Program FilesPolyspaceR2021abinwin64mlutil.dll+03183987 cmddistributor::PackagedTaskIIP::~PackagedTaskIIP+00000051
[ 10] 0x00007fff3f0bfeb5 C:Program FilesPolyspaceR2021abinwin64mlutil.dll+03145397 cmddistributor::CmdRequestTraits<cmddistributor::FcnCmdRequest<void> >::operator=+00001797
[ 11] 0x00007fff3f0c0ffb C:Program FilesPolyspaceR2021abinwin64mlutil.dll+03149819 cmddistributor::CmdRequestTraits<cmddistributor::FcnCmdRequest<void> >::operator=+00006219
[ 12] 0x00007fff3ac6cd1f C:Program FilesPolyspaceR2021abinwin64iqm.dll+00773407 iqm::IqmPlugin<cmddistributor::PackagedTaskIIP>::~IqmPlugin<cmddistributor::PackagedTaskIIP>+00000063
[ 13] 0x00007fff3aa7c6e3 C:Program FilesPolyspaceR2021abinwin64mcr.dll+00509667 services::lmgr::exception::LicensingStartupException::~LicensingStartupException+00002691
[ 14] 0x00007fff3ac3f157 C:Program FilesPolyspaceR2021abinwin64iqm.dll+00586071 iqm::Iqm::setupIqmFcnPtrs+00076359
[ 15] 0x00007fff3ac42904 C:Program FilesPolyspaceR2021abinwin64iqm.dll+00600324 iqm::Iqm::setupIqmFcnPtrs+00090612
[ 16] 0x00007fff3ac6fbfb C:Program FilesPolyspaceR2021abinwin64iqm.dll+00785403 iqm::PackagedTaskPlugin::~PackagedTaskPlugin+00010635
[ 17] 0x00007fff3ac1836a C:Program FilesPolyspaceR2021abinwin64iqm.dll+00426858 iqm::Iqm::create+00011498
[ 18] 0x00007fff3ac17c32 C:Program FilesPolyspaceR2021abinwin64iqm.dll+00425010 iqm::Iqm::create+00009650
[ 19] 0x00007fff3aa558fc C:Program FilesPolyspaceR2021abinwin64mcr.dll+00350460 mcrInstantiationError::operator=+00010428
[ 20] 0x00007fff3aa564ac C:Program FilesPolyspaceR2021abinwin64mcr.dll+00353452 mcrInstantiationError::operator=+00013420
[ 21] 0x00007fff3aa53ac0 C:Program FilesPolyspaceR2021abinwin64mcr.dll+00342720 mcrInstantiationError::operator=+00002688
[ 22] 0x00007fff93d49b9a C:Program FilesPolyspaceR2021abinwin64mwboost_thread-vc142-mt-x64-1_72.dll+00039834 mwboost::thread::swap+00000074
[ 23] 0x00007fffae8e9363 C:WINDOWSSystem32ucrtbase.dll+00168803 recalloc+00000163
[ 24] 0x00007fffaec2257d C:WINDOWSSystem32KERNEL32.dll+00075133 BaseThreadInitThunk+00000029
[ 25] 0x00007fffb0e6aa58 C:WINDOWSSYSTEM32ntdll.dll+00371288 RtlUserThreadStart+00000040
I don’t understand or know how to interpret this and fix this issue, any help would be appreciated in resolving this crashing issue! library compiler, .net assembly MATLAB Answers — New Questions
How do I set up fmincon correctly for parallel computation? “Supplied objective function must return a scalar value”
I have an expensive objective function which takes in multiple parameters, while the contraints are constant. It looks something like this:
out1, out2 = obj_func(in1, in2)
in1 has 1000 different cases. For each possible value of in1, I want to minimize out1 by adjusting in2. At the same time, out2 has to be < 1 in all cases. Because obj_func takes a while to run, I want to parallelize the computation, either by calculating several gradients at the same time, or solve the problem for several in1.
Below is my simplified code:
nPoints = length(INVARS(:,1));
odInputNames = {‘DISA’; ‘ALT’; ‘MACH’};
% Number of batches depending on given batch size:
sizeBatch = 20;
nBatch = floor( nPoints/sizeBatch ) + 1; % Last batch contains remaining points
% Define constraints
CONSTR = struct(…
‘param_A’, ‘…’,…
‘param_B’, ‘…’,…
‘param_C’, ‘…’,…
CONSTR_REQ = [ 1800; …
1.10; …
1.15; …
];
for i = 1:nBatch
% Create batchwise input vectors
for iODVar = 1:length(odInputNames)
if i < nBatch
OD.(odInputNames{iODVar}) = INVARS(sizeBatch*(i-1)+1:sizeBatch*i, iODVar);
else
OD.(odInputNames{iODVar}) = INVARS(sizeBatch*(i-1)+1:end, iODVar); % Last batch has fewer points
end
end
% Setup of FMINCON Optimizer
% ———————————————————————
A = [];
b = [];
Aeq = [];
beq = [];
lb = ones(size(OD.DISA)) * 120;
ub = ones(size(OD.DISA)) * 80;
options = optimoptions(@fmincon, …
‘Algorithm’, ‘active-set’,…
‘MaxIter’, 200,…
‘ConstraintTolerance’, 1e-8,…
‘OptimalityTolerance’, 1e-8,…
‘Display’, ‘off’,…
‘UseParallel’, true);
x0 = ones(size(OD.DISA)) * 85;
% Declare constraint results to be shared between obj_fun and con_fun
constr_fields = fieldnames(CONSTR);
con_res = zeros(length(constr_fields), length(OD.DISA));
% Execute Optimizer
[PLA_max, obj_min,exitflag,~,~] = fmincon( @(x)obj_fun(x), x0, A, b, Aeq, beq, lb, ub, @(x)con_fun(), options );
% Objective:
function [obj] = obj_fun( PLA )
OD.PLA = PLA;
[OD.OUT, OD.IN] = expensive_function( DES, OD );
obj = – OD.OUT.param_obj;
for i=1:length(constr_fields)
con_res(i,:) = eval([‘OD.’ CONSTR.(constr_fields{i})]);
end
end
% Constraints:
function [c,ceq] = con_fun()
exp_CONSTR_REQ = repmat(CONSTR_REQ, 1, length(OD.DISA));
c = (con_res – exp_CONSTR_REQ); % Non-Equality constraint ( !<= 0 )
ceq = [];
end
It works fine when I solve one case at a time, but when I try to parallelize it I got this error. How can I fix it?
Error using fminunc (line 348)
Supplied objective function must return a scalar value.I have an expensive objective function which takes in multiple parameters, while the contraints are constant. It looks something like this:
out1, out2 = obj_func(in1, in2)
in1 has 1000 different cases. For each possible value of in1, I want to minimize out1 by adjusting in2. At the same time, out2 has to be < 1 in all cases. Because obj_func takes a while to run, I want to parallelize the computation, either by calculating several gradients at the same time, or solve the problem for several in1.
Below is my simplified code:
nPoints = length(INVARS(:,1));
odInputNames = {‘DISA’; ‘ALT’; ‘MACH’};
% Number of batches depending on given batch size:
sizeBatch = 20;
nBatch = floor( nPoints/sizeBatch ) + 1; % Last batch contains remaining points
% Define constraints
CONSTR = struct(…
‘param_A’, ‘…’,…
‘param_B’, ‘…’,…
‘param_C’, ‘…’,…
CONSTR_REQ = [ 1800; …
1.10; …
1.15; …
];
for i = 1:nBatch
% Create batchwise input vectors
for iODVar = 1:length(odInputNames)
if i < nBatch
OD.(odInputNames{iODVar}) = INVARS(sizeBatch*(i-1)+1:sizeBatch*i, iODVar);
else
OD.(odInputNames{iODVar}) = INVARS(sizeBatch*(i-1)+1:end, iODVar); % Last batch has fewer points
end
end
% Setup of FMINCON Optimizer
% ———————————————————————
A = [];
b = [];
Aeq = [];
beq = [];
lb = ones(size(OD.DISA)) * 120;
ub = ones(size(OD.DISA)) * 80;
options = optimoptions(@fmincon, …
‘Algorithm’, ‘active-set’,…
‘MaxIter’, 200,…
‘ConstraintTolerance’, 1e-8,…
‘OptimalityTolerance’, 1e-8,…
‘Display’, ‘off’,…
‘UseParallel’, true);
x0 = ones(size(OD.DISA)) * 85;
% Declare constraint results to be shared between obj_fun and con_fun
constr_fields = fieldnames(CONSTR);
con_res = zeros(length(constr_fields), length(OD.DISA));
% Execute Optimizer
[PLA_max, obj_min,exitflag,~,~] = fmincon( @(x)obj_fun(x), x0, A, b, Aeq, beq, lb, ub, @(x)con_fun(), options );
% Objective:
function [obj] = obj_fun( PLA )
OD.PLA = PLA;
[OD.OUT, OD.IN] = expensive_function( DES, OD );
obj = – OD.OUT.param_obj;
for i=1:length(constr_fields)
con_res(i,:) = eval([‘OD.’ CONSTR.(constr_fields{i})]);
end
end
% Constraints:
function [c,ceq] = con_fun()
exp_CONSTR_REQ = repmat(CONSTR_REQ, 1, length(OD.DISA));
c = (con_res – exp_CONSTR_REQ); % Non-Equality constraint ( !<= 0 )
ceq = [];
end
It works fine when I solve one case at a time, but when I try to parallelize it I got this error. How can I fix it?
Error using fminunc (line 348)
Supplied objective function must return a scalar value. I have an expensive objective function which takes in multiple parameters, while the contraints are constant. It looks something like this:
out1, out2 = obj_func(in1, in2)
in1 has 1000 different cases. For each possible value of in1, I want to minimize out1 by adjusting in2. At the same time, out2 has to be < 1 in all cases. Because obj_func takes a while to run, I want to parallelize the computation, either by calculating several gradients at the same time, or solve the problem for several in1.
Below is my simplified code:
nPoints = length(INVARS(:,1));
odInputNames = {‘DISA’; ‘ALT’; ‘MACH’};
% Number of batches depending on given batch size:
sizeBatch = 20;
nBatch = floor( nPoints/sizeBatch ) + 1; % Last batch contains remaining points
% Define constraints
CONSTR = struct(…
‘param_A’, ‘…’,…
‘param_B’, ‘…’,…
‘param_C’, ‘…’,…
CONSTR_REQ = [ 1800; …
1.10; …
1.15; …
];
for i = 1:nBatch
% Create batchwise input vectors
for iODVar = 1:length(odInputNames)
if i < nBatch
OD.(odInputNames{iODVar}) = INVARS(sizeBatch*(i-1)+1:sizeBatch*i, iODVar);
else
OD.(odInputNames{iODVar}) = INVARS(sizeBatch*(i-1)+1:end, iODVar); % Last batch has fewer points
end
end
% Setup of FMINCON Optimizer
% ———————————————————————
A = [];
b = [];
Aeq = [];
beq = [];
lb = ones(size(OD.DISA)) * 120;
ub = ones(size(OD.DISA)) * 80;
options = optimoptions(@fmincon, …
‘Algorithm’, ‘active-set’,…
‘MaxIter’, 200,…
‘ConstraintTolerance’, 1e-8,…
‘OptimalityTolerance’, 1e-8,…
‘Display’, ‘off’,…
‘UseParallel’, true);
x0 = ones(size(OD.DISA)) * 85;
% Declare constraint results to be shared between obj_fun and con_fun
constr_fields = fieldnames(CONSTR);
con_res = zeros(length(constr_fields), length(OD.DISA));
% Execute Optimizer
[PLA_max, obj_min,exitflag,~,~] = fmincon( @(x)obj_fun(x), x0, A, b, Aeq, beq, lb, ub, @(x)con_fun(), options );
% Objective:
function [obj] = obj_fun( PLA )
OD.PLA = PLA;
[OD.OUT, OD.IN] = expensive_function( DES, OD );
obj = – OD.OUT.param_obj;
for i=1:length(constr_fields)
con_res(i,:) = eval([‘OD.’ CONSTR.(constr_fields{i})]);
end
end
% Constraints:
function [c,ceq] = con_fun()
exp_CONSTR_REQ = repmat(CONSTR_REQ, 1, length(OD.DISA));
c = (con_res – exp_CONSTR_REQ); % Non-Equality constraint ( !<= 0 )
ceq = [];
end
It works fine when I solve one case at a time, but when I try to parallelize it I got this error. How can I fix it?
Error using fminunc (line 348)
Supplied objective function must return a scalar value. fmincon, optimization, parallel computing MATLAB Answers — New Questions
Can not Autotune PID controller for DC motor with Arduino feedback speed through encoder
First I wanted to control speed of 4 DC motors for a robot with 4 Mecnum wheels, But i faced the problem of analog world which is the speed of each dc motor differs from the other so the robot could not move with the correct path i want (specific speed in direction with angles). So i decided to control each motor with a digital IR encoder and PWM channel from arduino with PID but i can not find the correct values of Kp, Ki, Kd to control the motor so after some search i found PID autotuner (closed loop – open loop) but after integreating each of them in simulink it tells me always the tuned gains are not ready so what should i do to FIND MY KP, KI, KD.First I wanted to control speed of 4 DC motors for a robot with 4 Mecnum wheels, But i faced the problem of analog world which is the speed of each dc motor differs from the other so the robot could not move with the correct path i want (specific speed in direction with angles). So i decided to control each motor with a digital IR encoder and PWM channel from arduino with PID but i can not find the correct values of Kp, Ki, Kd to control the motor so after some search i found PID autotuner (closed loop – open loop) but after integreating each of them in simulink it tells me always the tuned gains are not ready so what should i do to FIND MY KP, KI, KD. First I wanted to control speed of 4 DC motors for a robot with 4 Mecnum wheels, But i faced the problem of analog world which is the speed of each dc motor differs from the other so the robot could not move with the correct path i want (specific speed in direction with angles). So i decided to control each motor with a digital IR encoder and PWM channel from arduino with PID but i can not find the correct values of Kp, Ki, Kd to control the motor so after some search i found PID autotuner (closed loop – open loop) but after integreating each of them in simulink it tells me always the tuned gains are not ready so what should i do to FIND MY KP, KI, KD. pid, arduino, dc motor MATLAB Answers — New Questions
Adjust classifier performance (sensitivity & specificity)
Hi all,
I’m trying to build a classifier for my highly imbalanced binaty data, where I have the following stats:
tabulate(classes)
Value Count Percent
0 133412 97.62%
1 3247 2.38%
My dataset has 119 features. My question is: how can I balance my classifier sensitivity and specificity results (see more details below)?
In order to deal with my imbalanced data, I’m using the ensemble classifier with the RUSBoost Method, and acessing its performance, like shown in the code below:
%% Set cross validation – holdout
part = cvpartition(classes, ‘Holdout’, 0.5);
istrain = training(part); % Data for fitting
istest = test(part); % Data for quality assessment
holdout_train_features = features(istrain,:);
holdout_train_classes = classes(istrain);
holdout_test_features = features(istest,:);
holdout_test_classes = classes(istest);
%% Set classifier
% Set template tree
max_mum_splits = round(sum(istrain)/2);
t = templateTree(‘MaxNumSplits’, max_num_splits);
classifier = fitcensemble(holdout_train_features, holdout_train_classes, ‘Method’,’RUSBoost’, …
‘NumLearningCycles’, 1000, ‘Learners’, t,’LearnRate’, 0.1);
%% Test performance
% Get common classification indicators
[obtained_classes, scores] = predict(classifier, holdout_test_features);
holdout_validation_results = confusionchart(holdout_test_classes, obtained_classes);
TN = holdout_validation_results.NormalizedValues(1,1);
TP = holdout_validation_results.NormalizedValues(2,2);
FP = holdout_validation_results.NormalizedValues(1,2);
FN = holdout_validation_results.NormalizedValues(2,1);
accuracy = (TP + TN)/(TP + TN + FP + FN); % 0.99406
sensitivity = TP/(TP + FN); % 0.86445
specificity = TN/(TN + FP); % 0.99721
PPV = TP/(TP + FP); % 0.88295
NPV = TN/(TN + FN); % 0.9967
% Compute ROC curve
positiveClassIdx = find(classifier.ClassNames == 1);
[X,Y,T,AUC, OPTROCPT] = perfcurve(holdout_test_classes, scores(:,positiveClassIdx), 1);
plot(1-X,Y)
hold on
scatter(1-OPTROCPT(1),OPTROCPT(2), ‘filled’)
xlabel(‘Specificity’)
ylabel(‘Sensitivity’)
Which gets me the following:
As can be appreciated, I get an imbalanced value of specificity (very high) and sensitivity (low). My question is: how can I adjust my classifier in order to balance the sensitivity and specificity (and PPV and NPV, of course), so that it matched my desired balance (e.g., what I show in the ROC curve: 0.97 specificity and 0.961 sensitivity)?
Many thanks for your attention,
DiogoHi all,
I’m trying to build a classifier for my highly imbalanced binaty data, where I have the following stats:
tabulate(classes)
Value Count Percent
0 133412 97.62%
1 3247 2.38%
My dataset has 119 features. My question is: how can I balance my classifier sensitivity and specificity results (see more details below)?
In order to deal with my imbalanced data, I’m using the ensemble classifier with the RUSBoost Method, and acessing its performance, like shown in the code below:
%% Set cross validation – holdout
part = cvpartition(classes, ‘Holdout’, 0.5);
istrain = training(part); % Data for fitting
istest = test(part); % Data for quality assessment
holdout_train_features = features(istrain,:);
holdout_train_classes = classes(istrain);
holdout_test_features = features(istest,:);
holdout_test_classes = classes(istest);
%% Set classifier
% Set template tree
max_mum_splits = round(sum(istrain)/2);
t = templateTree(‘MaxNumSplits’, max_num_splits);
classifier = fitcensemble(holdout_train_features, holdout_train_classes, ‘Method’,’RUSBoost’, …
‘NumLearningCycles’, 1000, ‘Learners’, t,’LearnRate’, 0.1);
%% Test performance
% Get common classification indicators
[obtained_classes, scores] = predict(classifier, holdout_test_features);
holdout_validation_results = confusionchart(holdout_test_classes, obtained_classes);
TN = holdout_validation_results.NormalizedValues(1,1);
TP = holdout_validation_results.NormalizedValues(2,2);
FP = holdout_validation_results.NormalizedValues(1,2);
FN = holdout_validation_results.NormalizedValues(2,1);
accuracy = (TP + TN)/(TP + TN + FP + FN); % 0.99406
sensitivity = TP/(TP + FN); % 0.86445
specificity = TN/(TN + FP); % 0.99721
PPV = TP/(TP + FP); % 0.88295
NPV = TN/(TN + FN); % 0.9967
% Compute ROC curve
positiveClassIdx = find(classifier.ClassNames == 1);
[X,Y,T,AUC, OPTROCPT] = perfcurve(holdout_test_classes, scores(:,positiveClassIdx), 1);
plot(1-X,Y)
hold on
scatter(1-OPTROCPT(1),OPTROCPT(2), ‘filled’)
xlabel(‘Specificity’)
ylabel(‘Sensitivity’)
Which gets me the following:
As can be appreciated, I get an imbalanced value of specificity (very high) and sensitivity (low). My question is: how can I adjust my classifier in order to balance the sensitivity and specificity (and PPV and NPV, of course), so that it matched my desired balance (e.g., what I show in the ROC curve: 0.97 specificity and 0.961 sensitivity)?
Many thanks for your attention,
Diogo Hi all,
I’m trying to build a classifier for my highly imbalanced binaty data, where I have the following stats:
tabulate(classes)
Value Count Percent
0 133412 97.62%
1 3247 2.38%
My dataset has 119 features. My question is: how can I balance my classifier sensitivity and specificity results (see more details below)?
In order to deal with my imbalanced data, I’m using the ensemble classifier with the RUSBoost Method, and acessing its performance, like shown in the code below:
%% Set cross validation – holdout
part = cvpartition(classes, ‘Holdout’, 0.5);
istrain = training(part); % Data for fitting
istest = test(part); % Data for quality assessment
holdout_train_features = features(istrain,:);
holdout_train_classes = classes(istrain);
holdout_test_features = features(istest,:);
holdout_test_classes = classes(istest);
%% Set classifier
% Set template tree
max_mum_splits = round(sum(istrain)/2);
t = templateTree(‘MaxNumSplits’, max_num_splits);
classifier = fitcensemble(holdout_train_features, holdout_train_classes, ‘Method’,’RUSBoost’, …
‘NumLearningCycles’, 1000, ‘Learners’, t,’LearnRate’, 0.1);
%% Test performance
% Get common classification indicators
[obtained_classes, scores] = predict(classifier, holdout_test_features);
holdout_validation_results = confusionchart(holdout_test_classes, obtained_classes);
TN = holdout_validation_results.NormalizedValues(1,1);
TP = holdout_validation_results.NormalizedValues(2,2);
FP = holdout_validation_results.NormalizedValues(1,2);
FN = holdout_validation_results.NormalizedValues(2,1);
accuracy = (TP + TN)/(TP + TN + FP + FN); % 0.99406
sensitivity = TP/(TP + FN); % 0.86445
specificity = TN/(TN + FP); % 0.99721
PPV = TP/(TP + FP); % 0.88295
NPV = TN/(TN + FN); % 0.9967
% Compute ROC curve
positiveClassIdx = find(classifier.ClassNames == 1);
[X,Y,T,AUC, OPTROCPT] = perfcurve(holdout_test_classes, scores(:,positiveClassIdx), 1);
plot(1-X,Y)
hold on
scatter(1-OPTROCPT(1),OPTROCPT(2), ‘filled’)
xlabel(‘Specificity’)
ylabel(‘Sensitivity’)
Which gets me the following:
As can be appreciated, I get an imbalanced value of specificity (very high) and sensitivity (low). My question is: how can I adjust my classifier in order to balance the sensitivity and specificity (and PPV and NPV, of course), so that it matched my desired balance (e.g., what I show in the ROC curve: 0.97 specificity and 0.961 sensitivity)?
Many thanks for your attention,
Diogo machine learning, performance, matlab, classification, ensemble learning MATLAB Answers — New Questions
I try to run code for precoding in spatial multiplexing in MIMO from the book MIMO OFDM wireless communication system book and the code doesnt work.
% pre_MMSE.m
%MIMO-OFDM Wireless Communications with MATLAB¢ç Yong Soo Cho, Jaekwon Kim, Won Young Yang and Chung G. Kang
%2010 John Wiley & Sons (Asia) Pte Ltd
clear all; clf
%%%%%% Parameter Setting %%%%%%%%%
N_frame=100; N_packet=1000;
b=2; M=2^b; % Number of bits per symbol and Modulation order
mod_obj=modem.qammod(‘M’,M,’SymbolOrder’,’Gray’,’InputType’,’bit’);
demod_obj = modem.qamdemod(mod_obj);
NT=4; NR=4; sq2=sqrt(2); I=eye(NR,NR);
N_pbits = N_frame*NT*b;
N_tbits = N_pbits*N_packet;
fprintf(‘====================================================n’);
fprintf(‘ Pre-MMSE transmission’);
fprintf(‘n %d x %d MIMOn %d QAM’, NT,NR,M);
fprintf(‘n Simulation bits : %d’,N_tbits);
fprintf(‘n====================================================n’);
SNRdBs = [0:2:20];
for i_SNR=1:length(SNRdBs)
SNRdB = SNRdBs(i_SNR);
noise_var = NT*0.5*10^(-SNRdB/10);
sigma = sqrt(noise_var);
rand(‘seed’,1); randn(‘seed’,1); N_ebits = 0;
%%%%%%%%%%%%% Transmitter %%%%%%%%%%%%%%%%%%
for i_packet=1:N_packet
msg_bit = randint(N_pbits,1); % bit generation
symbol = modulate(mod_obj,msg_bit).’;
Scale = modnorm(symbol,’avpow’,1); % normalization
Symbol_nomalized = reshape(Scale*symbol,NT,N_frame);
H = (randn(NR,NT)+j*randn(NR,NT))/sq2;
temp_W = H’*inv(H*H’+noise_var*I);
beta = sqrt(NT/trace(temp_W*temp_W’)); % Eq.(12.17)
W = beta*temp_W;
Tx_signal = W*Symbol_nomalized;
%%%%%%%%%%%%% Channel and Noise %%%%%%%%%%%%%
Rx_signal = H*Tx_signal+sigma*(randn(NR,N_frame)+j*randn(NR,N_frame));
%%%%%%%%%%%%%% Receiver %%%%%%%%%%%%%%%%%%%%%
y = Rx_signal/beta; % Eq.(12.18)
Symbol_hat = reshape(y/Scale,NT*N_frame,1);
msg_hat = demodulate(demod_obj,Symbol_hat);
N_ebits = N_ebits + sum(msg_hat~=msg_bit);
end
BER(i_SNR) = N_ebits/N_tbits;
end
semilogy(SNRdBs,BER,’-k^’,’LineWidth’,2); hold on; grid on;
xlabel(‘SNR[dB]’), ylabel(‘BER’);
legend(‘Pre-MMSE transmission’)
Question:
In the above code, there are lot of functions like modem.qammod , randint that are outdated and are not supported by MATLAB anymore but does have equivalent syntaxes that is supported by the current MATLAB bUT i couldnot find the equivalent of syntax ‘modulate’ anywhere in the google.Does someone know about this ?% pre_MMSE.m
%MIMO-OFDM Wireless Communications with MATLAB¢ç Yong Soo Cho, Jaekwon Kim, Won Young Yang and Chung G. Kang
%2010 John Wiley & Sons (Asia) Pte Ltd
clear all; clf
%%%%%% Parameter Setting %%%%%%%%%
N_frame=100; N_packet=1000;
b=2; M=2^b; % Number of bits per symbol and Modulation order
mod_obj=modem.qammod(‘M’,M,’SymbolOrder’,’Gray’,’InputType’,’bit’);
demod_obj = modem.qamdemod(mod_obj);
NT=4; NR=4; sq2=sqrt(2); I=eye(NR,NR);
N_pbits = N_frame*NT*b;
N_tbits = N_pbits*N_packet;
fprintf(‘====================================================n’);
fprintf(‘ Pre-MMSE transmission’);
fprintf(‘n %d x %d MIMOn %d QAM’, NT,NR,M);
fprintf(‘n Simulation bits : %d’,N_tbits);
fprintf(‘n====================================================n’);
SNRdBs = [0:2:20];
for i_SNR=1:length(SNRdBs)
SNRdB = SNRdBs(i_SNR);
noise_var = NT*0.5*10^(-SNRdB/10);
sigma = sqrt(noise_var);
rand(‘seed’,1); randn(‘seed’,1); N_ebits = 0;
%%%%%%%%%%%%% Transmitter %%%%%%%%%%%%%%%%%%
for i_packet=1:N_packet
msg_bit = randint(N_pbits,1); % bit generation
symbol = modulate(mod_obj,msg_bit).’;
Scale = modnorm(symbol,’avpow’,1); % normalization
Symbol_nomalized = reshape(Scale*symbol,NT,N_frame);
H = (randn(NR,NT)+j*randn(NR,NT))/sq2;
temp_W = H’*inv(H*H’+noise_var*I);
beta = sqrt(NT/trace(temp_W*temp_W’)); % Eq.(12.17)
W = beta*temp_W;
Tx_signal = W*Symbol_nomalized;
%%%%%%%%%%%%% Channel and Noise %%%%%%%%%%%%%
Rx_signal = H*Tx_signal+sigma*(randn(NR,N_frame)+j*randn(NR,N_frame));
%%%%%%%%%%%%%% Receiver %%%%%%%%%%%%%%%%%%%%%
y = Rx_signal/beta; % Eq.(12.18)
Symbol_hat = reshape(y/Scale,NT*N_frame,1);
msg_hat = demodulate(demod_obj,Symbol_hat);
N_ebits = N_ebits + sum(msg_hat~=msg_bit);
end
BER(i_SNR) = N_ebits/N_tbits;
end
semilogy(SNRdBs,BER,’-k^’,’LineWidth’,2); hold on; grid on;
xlabel(‘SNR[dB]’), ylabel(‘BER’);
legend(‘Pre-MMSE transmission’)
Question:
In the above code, there are lot of functions like modem.qammod , randint that are outdated and are not supported by MATLAB anymore but does have equivalent syntaxes that is supported by the current MATLAB bUT i couldnot find the equivalent of syntax ‘modulate’ anywhere in the google.Does someone know about this ? % pre_MMSE.m
%MIMO-OFDM Wireless Communications with MATLAB¢ç Yong Soo Cho, Jaekwon Kim, Won Young Yang and Chung G. Kang
%2010 John Wiley & Sons (Asia) Pte Ltd
clear all; clf
%%%%%% Parameter Setting %%%%%%%%%
N_frame=100; N_packet=1000;
b=2; M=2^b; % Number of bits per symbol and Modulation order
mod_obj=modem.qammod(‘M’,M,’SymbolOrder’,’Gray’,’InputType’,’bit’);
demod_obj = modem.qamdemod(mod_obj);
NT=4; NR=4; sq2=sqrt(2); I=eye(NR,NR);
N_pbits = N_frame*NT*b;
N_tbits = N_pbits*N_packet;
fprintf(‘====================================================n’);
fprintf(‘ Pre-MMSE transmission’);
fprintf(‘n %d x %d MIMOn %d QAM’, NT,NR,M);
fprintf(‘n Simulation bits : %d’,N_tbits);
fprintf(‘n====================================================n’);
SNRdBs = [0:2:20];
for i_SNR=1:length(SNRdBs)
SNRdB = SNRdBs(i_SNR);
noise_var = NT*0.5*10^(-SNRdB/10);
sigma = sqrt(noise_var);
rand(‘seed’,1); randn(‘seed’,1); N_ebits = 0;
%%%%%%%%%%%%% Transmitter %%%%%%%%%%%%%%%%%%
for i_packet=1:N_packet
msg_bit = randint(N_pbits,1); % bit generation
symbol = modulate(mod_obj,msg_bit).’;
Scale = modnorm(symbol,’avpow’,1); % normalization
Symbol_nomalized = reshape(Scale*symbol,NT,N_frame);
H = (randn(NR,NT)+j*randn(NR,NT))/sq2;
temp_W = H’*inv(H*H’+noise_var*I);
beta = sqrt(NT/trace(temp_W*temp_W’)); % Eq.(12.17)
W = beta*temp_W;
Tx_signal = W*Symbol_nomalized;
%%%%%%%%%%%%% Channel and Noise %%%%%%%%%%%%%
Rx_signal = H*Tx_signal+sigma*(randn(NR,N_frame)+j*randn(NR,N_frame));
%%%%%%%%%%%%%% Receiver %%%%%%%%%%%%%%%%%%%%%
y = Rx_signal/beta; % Eq.(12.18)
Symbol_hat = reshape(y/Scale,NT*N_frame,1);
msg_hat = demodulate(demod_obj,Symbol_hat);
N_ebits = N_ebits + sum(msg_hat~=msg_bit);
end
BER(i_SNR) = N_ebits/N_tbits;
end
semilogy(SNRdBs,BER,’-k^’,’LineWidth’,2); hold on; grid on;
xlabel(‘SNR[dB]’), ylabel(‘BER’);
legend(‘Pre-MMSE transmission’)
Question:
In the above code, there are lot of functions like modem.qammod , randint that are outdated and are not supported by MATLAB anymore but does have equivalent syntaxes that is supported by the current MATLAB bUT i couldnot find the equivalent of syntax ‘modulate’ anywhere in the google.Does someone know about this ? help-answer MATLAB Answers — New Questions
Contour not taking into account edge of domain
Hello eveyone,
I have an issue using contour (contourf or contourc as well) with convhull in order to get the convex polygon that includes the domain where Z=1.
When i try to retrieve the contour matrix, only the coordinates contained are those of strictly inside the domain, and the edges of the domain do not appear, then the polygon I get is way smaller than I expect.
I hope this is rather clear. Thank you in advance!
Here is my code
X = 1:0.2:2;
Y = 2:0.2:3;
[X_mesh,Y_mesh]=meshgrid(X,Y);
Z = [1 1 1 0 0 0;
1 1 1 1 0 0;
1 1 1 0 0 0;
1 1 1 1 1 1;
1 1 1 1 1 1;
1 1 1 1 1 1];
figure,
[M,h]=contourf(X_mesh,Y_mesh,Z,[1 1]);
M
coords_x=M(1,2:end);
coords_y=M(2,2:end);
K=convhull(coords_x,coords_y);
figure,hold on,
contourf(X_mesh,Y_mesh,Z,[1 1]);
patch(coords_x(K),coords_y(K),’green’, ‘FaceAlpha’, 0.5);Hello eveyone,
I have an issue using contour (contourf or contourc as well) with convhull in order to get the convex polygon that includes the domain where Z=1.
When i try to retrieve the contour matrix, only the coordinates contained are those of strictly inside the domain, and the edges of the domain do not appear, then the polygon I get is way smaller than I expect.
I hope this is rather clear. Thank you in advance!
Here is my code
X = 1:0.2:2;
Y = 2:0.2:3;
[X_mesh,Y_mesh]=meshgrid(X,Y);
Z = [1 1 1 0 0 0;
1 1 1 1 0 0;
1 1 1 0 0 0;
1 1 1 1 1 1;
1 1 1 1 1 1;
1 1 1 1 1 1];
figure,
[M,h]=contourf(X_mesh,Y_mesh,Z,[1 1]);
M
coords_x=M(1,2:end);
coords_y=M(2,2:end);
K=convhull(coords_x,coords_y);
figure,hold on,
contourf(X_mesh,Y_mesh,Z,[1 1]);
patch(coords_x(K),coords_y(K),’green’, ‘FaceAlpha’, 0.5); Hello eveyone,
I have an issue using contour (contourf or contourc as well) with convhull in order to get the convex polygon that includes the domain where Z=1.
When i try to retrieve the contour matrix, only the coordinates contained are those of strictly inside the domain, and the edges of the domain do not appear, then the polygon I get is way smaller than I expect.
I hope this is rather clear. Thank you in advance!
Here is my code
X = 1:0.2:2;
Y = 2:0.2:3;
[X_mesh,Y_mesh]=meshgrid(X,Y);
Z = [1 1 1 0 0 0;
1 1 1 1 0 0;
1 1 1 0 0 0;
1 1 1 1 1 1;
1 1 1 1 1 1;
1 1 1 1 1 1];
figure,
[M,h]=contourf(X_mesh,Y_mesh,Z,[1 1]);
M
coords_x=M(1,2:end);
coords_y=M(2,2:end);
K=convhull(coords_x,coords_y);
figure,hold on,
contourf(X_mesh,Y_mesh,Z,[1 1]);
patch(coords_x(K),coords_y(K),’green’, ‘FaceAlpha’, 0.5); contour, convhull, edges, polygon MATLAB Answers — New Questions
Lane Keeping Assist with Lane Detection/unreal engine
Is it possible to make "
Lane Keeping Assist with Lane Detection
"visualize in unreal engine?Is it possible to make "
Lane Keeping Assist with Lane Detection
"visualize in unreal engine? Is it possible to make "
Lane Keeping Assist with Lane Detection
"visualize in unreal engine? lane keeping matlab MATLAB Answers — New Questions
Human body model contact simulation
Hello,
I would like to simulate a robot arm that comes into contact with a human during its movement.
Is there a human model for Simulink Multibody where I can display the contact forces and accelerations at the contact points?
Thank you for your help.Hello,
I would like to simulate a robot arm that comes into contact with a human during its movement.
Is there a human model for Simulink Multibody where I can display the contact forces and accelerations at the contact points?
Thank you for your help. Hello,
I would like to simulate a robot arm that comes into contact with a human during its movement.
Is there a human model for Simulink Multibody where I can display the contact forces and accelerations at the contact points?
Thank you for your help. human body MATLAB Answers — New Questions
Why do I see different measured values for frequency of the same three phase electrical signal while using different PLL & PMU block types?
Hi Community,
I have modelled a grid using a programmable three phase AC voltage source and there are three loads attached to it. Model & Parameter file is attached. The loads 2 and 3 are switched off at T = 2 secs and switched back on at T = 4 secs.
I want to measure the frequency deviation in the 3-ph electrical voltage (magnitude, direction and time duration of instability) during sudden load shedding & load reconnection.
For this I used PLL blocks. Now, Simulink offers a few options for PLL & PLL based PMU blocks and my issue is that each of these blocks gives me a different result for the exact same scenario. I want to know how much frequency deviation is happening, but with each block giving me varying results, how do I conclude which result is accurate?
Frequency Meausurement Outputs
Types of PLL & PMU blocks used
Method 1: Sinusoidal Measurement (PLL, Three-Phase)
Method 2: PLL (3ph)
Method 3: Phasor Measurement Unit (PMU, Three-Phase)
Method 4: PMU (PLL-Based, Positive-Sequence)
Main Model
My base assumption is – frequency deviation in voltage is inherent attribute of the voltage. No matter the measuring mechanism, a frequency of 50 Hz should be measured as 50 Hz +- tolerance.
The same conceptual doubt also extends to the gains of the PLL block. Modifying the gain will affect one or more of frequency deviation characteristics (magnitude, direction and time duration of instability). So how do I narrow down on what gain values would be appropriate?Hi Community,
I have modelled a grid using a programmable three phase AC voltage source and there are three loads attached to it. Model & Parameter file is attached. The loads 2 and 3 are switched off at T = 2 secs and switched back on at T = 4 secs.
I want to measure the frequency deviation in the 3-ph electrical voltage (magnitude, direction and time duration of instability) during sudden load shedding & load reconnection.
For this I used PLL blocks. Now, Simulink offers a few options for PLL & PLL based PMU blocks and my issue is that each of these blocks gives me a different result for the exact same scenario. I want to know how much frequency deviation is happening, but with each block giving me varying results, how do I conclude which result is accurate?
Frequency Meausurement Outputs
Types of PLL & PMU blocks used
Method 1: Sinusoidal Measurement (PLL, Three-Phase)
Method 2: PLL (3ph)
Method 3: Phasor Measurement Unit (PMU, Three-Phase)
Method 4: PMU (PLL-Based, Positive-Sequence)
Main Model
My base assumption is – frequency deviation in voltage is inherent attribute of the voltage. No matter the measuring mechanism, a frequency of 50 Hz should be measured as 50 Hz +- tolerance.
The same conceptual doubt also extends to the gains of the PLL block. Modifying the gain will affect one or more of frequency deviation characteristics (magnitude, direction and time duration of instability). So how do I narrow down on what gain values would be appropriate? Hi Community,
I have modelled a grid using a programmable three phase AC voltage source and there are three loads attached to it. Model & Parameter file is attached. The loads 2 and 3 are switched off at T = 2 secs and switched back on at T = 4 secs.
I want to measure the frequency deviation in the 3-ph electrical voltage (magnitude, direction and time duration of instability) during sudden load shedding & load reconnection.
For this I used PLL blocks. Now, Simulink offers a few options for PLL & PLL based PMU blocks and my issue is that each of these blocks gives me a different result for the exact same scenario. I want to know how much frequency deviation is happening, but with each block giving me varying results, how do I conclude which result is accurate?
Frequency Meausurement Outputs
Types of PLL & PMU blocks used
Method 1: Sinusoidal Measurement (PLL, Three-Phase)
Method 2: PLL (3ph)
Method 3: Phasor Measurement Unit (PMU, Three-Phase)
Method 4: PMU (PLL-Based, Positive-Sequence)
Main Model
My base assumption is – frequency deviation in voltage is inherent attribute of the voltage. No matter the measuring mechanism, a frequency of 50 Hz should be measured as 50 Hz +- tolerance.
The same conceptual doubt also extends to the gains of the PLL block. Modifying the gain will affect one or more of frequency deviation characteristics (magnitude, direction and time duration of instability). So how do I narrow down on what gain values would be appropriate? simulink, frequency measurement, pll, pmu, three phase electrical signals MATLAB Answers — New Questions
I calculated IdIq as an equation in the experimental data 3 phase current, but the value is weird.
I’m comparing the output of the IdIq map with the input of RPM and torque and IdIq in the experimental data. I calculated IdIq with the equation as shown in the capture picture in the 3 phase current, which is the dynamo experimental data. But the value level doesn’t match the map value. The value in the map is id -280,iq 89. The result of calculation is id 0,iq300. Is there something wrong with the equation below? I’ve selected all the D-axis and Q-axis in the ParkTransform library, but id iq only change the value.I’m comparing the output of the IdIq map with the input of RPM and torque and IdIq in the experimental data. I calculated IdIq with the equation as shown in the capture picture in the 3 phase current, which is the dynamo experimental data. But the value level doesn’t match the map value. The value in the map is id -280,iq 89. The result of calculation is id 0,iq300. Is there something wrong with the equation below? I’ve selected all the D-axis and Q-axis in the ParkTransform library, but id iq only change the value. I’m comparing the output of the IdIq map with the input of RPM and torque and IdIq in the experimental data. I calculated IdIq with the equation as shown in the capture picture in the 3 phase current, which is the dynamo experimental data. But the value level doesn’t match the map value. The value in the map is id -280,iq 89. The result of calculation is id 0,iq300. Is there something wrong with the equation below? I’ve selected all the D-axis and Q-axis in the ParkTransform library, but id iq only change the value. idiq calculation MATLAB Answers — New Questions
How to set unit properties for arrays in simulink?
I have 3×1 positionArray such as [latitude, longitude, altitude] and units are [rad,rad,m].
This array is in the input for simulink. Is there any way to define different units for array in simulink?
In the "Signal Attributes" section, i tried:
rad, rad, m
rad_rad_m
[rad,rad,m]
{rad,rad,m}
nothing works.
Unit specifications are explained in following link, but there is no information about array units.
https://www.mathworks.com/help/simulink/ug/units-in-simulink.htmlI have 3×1 positionArray such as [latitude, longitude, altitude] and units are [rad,rad,m].
This array is in the input for simulink. Is there any way to define different units for array in simulink?
In the "Signal Attributes" section, i tried:
rad, rad, m
rad_rad_m
[rad,rad,m]
{rad,rad,m}
nothing works.
Unit specifications are explained in following link, but there is no information about array units.
https://www.mathworks.com/help/simulink/ug/units-in-simulink.html I have 3×1 positionArray such as [latitude, longitude, altitude] and units are [rad,rad,m].
This array is in the input for simulink. Is there any way to define different units for array in simulink?
In the "Signal Attributes" section, i tried:
rad, rad, m
rad_rad_m
[rad,rad,m]
{rad,rad,m}
nothing works.
Unit specifications are explained in following link, but there is no information about array units.
https://www.mathworks.com/help/simulink/ug/units-in-simulink.html signal attributes, unit, array MATLAB Answers — New Questions
how to implement lifi communication in matlab?
how to implement lifi communication in matlab?how to implement lifi communication in matlab? how to implement lifi communication in matlab? lifi-matlab MATLAB Answers — New Questions
how to simulate lifi transmitter and reciever using simulink
i need to simulate lifi technology transmitter and reciever using matlab simulink….also need help to use led block in simulink….i have the led block that has terminals as anode and cathode…..need led block as having only input and output terminals as they are the final block of my transmitter section.i need to simulate lifi technology transmitter and reciever using matlab simulink….also need help to use led block in simulink….i have the led block that has terminals as anode and cathode…..need led block as having only input and output terminals as they are the final block of my transmitter section. i need to simulate lifi technology transmitter and reciever using matlab simulink….also need help to use led block in simulink….i have the led block that has terminals as anode and cathode…..need led block as having only input and output terminals as they are the final block of my transmitter section. lifi, simulink, led, visible light communication, transmitter, reciever, simulation MATLAB Answers — New Questions
ODBC interface for changing login way
Hi, is there a way before I pack a GUI to an exe file to make an interface for later changing the connection ODBC to SQL server after that in case that server IP is changed meanwhile? Or I must to recode the source code and pack again? Thanks! R2015aHi, is there a way before I pack a GUI to an exe file to make an interface for later changing the connection ODBC to SQL server after that in case that server IP is changed meanwhile? Or I must to recode the source code and pack again? Thanks! R2015a Hi, is there a way before I pack a GUI to an exe file to make an interface for later changing the connection ODBC to SQL server after that in case that server IP is changed meanwhile? Or I must to recode the source code and pack again? Thanks! R2015a sql, connection, interface MATLAB Answers — New Questions