Category: Matlab
Category Archives: Matlab
The problem about Simscape Battery MBC parameter estimate.
I am trying to calibrate my battery parameters using the MBC tool, but I encountered the following issue. I input the HPPC experimental data into the MBC tool and waited for it to fit the parameters, such as Em, R0, R1, etc. However, the results were disappointing. The fitting did not converge, and the curve could not be fitted at all. The result is shown in Figure 1 below. Could you please help me identify the issue? Is it a problem with my parameter settings in the MBC tool, or is there an issue with my HPPC experimental data?I am trying to calibrate my battery parameters using the MBC tool, but I encountered the following issue. I input the HPPC experimental data into the MBC tool and waited for it to fit the parameters, such as Em, R0, R1, etc. However, the results were disappointing. The fitting did not converge, and the curve could not be fitted at all. The result is shown in Figure 1 below. Could you please help me identify the issue? Is it a problem with my parameter settings in the MBC tool, or is there an issue with my HPPC experimental data? I am trying to calibrate my battery parameters using the MBC tool, but I encountered the following issue. I input the HPPC experimental data into the MBC tool and waited for it to fit the parameters, such as Em, R0, R1, etc. However, the results were disappointing. The fitting did not converge, and the curve could not be fitted at all. The result is shown in Figure 1 below. Could you please help me identify the issue? Is it a problem with my parameter settings in the MBC tool, or is there an issue with my HPPC experimental data? simscape, mbc, battery_system_management MATLAB Answers — New Questions
Code inspector not able to verify the state flow model
I am able to run model and generate the code, but when i run the code inspector, not able to varifiy the code, its failing
Please let me know, anyone faced this issue beforeI am able to run model and generate the code, but when i run the code inspector, not able to varifiy the code, its failing
Please let me know, anyone faced this issue before I am able to run model and generate the code, but when i run the code inspector, not able to varifiy the code, its failing
Please let me know, anyone faced this issue before state flow not able to verify the state flow chart MATLAB Answers — New Questions
C++ compiler errors TFlite
Good afternoon,
I have been trying to deploy a tflite model onto my raspberry pi using MATLAB 2024a.
To start i am using:
Example code (SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample).
Mex code setup i am using ‘Microsoft Visual C++ 2022’
Built Tensorflow 2.15 on Windows with Bazel 6.10
Downloaded and setup Raspberry pi Matlab config
Raspberry pi 32 bit bullseye (python 3.9.2)
created all of the paths accordingly as stated in Prerequisites for Deep Learning with TensorFlow Lite Models
When i run the code it has no errors. The problem starts once i run:
codegen -config cfg tflite_semantic_predict -args ones(257,257,3,’single’)
The error is as follows:
codegen -config cfg tflite_semantic_predict -args ones(257,257,3,’single’)
————————————————————————
Error executing command "touch -c /home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/*.*;make -j$(($(nproc)+1)) -Otarget -f tflite_semantic_predict_rtw.mk all MATLAB_WORKSPACE="/home/bmblaylock42/MATLAB_ws/R2024a" LINUX_TARGET_LIBS_MACRO="" -C /home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict LC_ALL=C". Details:
STDERR: In file included from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/model.h:26,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/kernels/register.h:22,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/kernels/register.h:18,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/invokeinterpreter.hpp:16,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/invokeinterpreter.cpp:6:
/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/interpreter_builder.h:33:10: fatal error: flatbuffers/flatbuffers.h: No such file or directory
33 | #include "flatbuffers/flatbuffers.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [tflite_semantic_predict_rtw.mk:382: invokeinterpreter.cpp.o] Error 1
make: *** Waiting for unfinished jobs….
In file included from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/model.h:26,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/kernels/register.h:22,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/kernels/register.h:18,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/invokeinterpreter.hpp:16,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict.cpp:15:
/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/interpreter_builder.h:33:10: fatal error: flatbuffers/flatbuffers.h: No such file or directory
33 | #include "flatbuffers/flatbuffers.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [tflite_semantic_predict_rtw.mk:398: tflite_semantic_predict.cpp.o] Error 1
STDOUT: make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"tflite_semantic_predict_data.cpp.dep" -MT"tflite_semantic_predict_data.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict_data.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict_data.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"tflite_semantic_predict_terminate.cpp.dep" -MT"tflite_semantic_predict_terminate.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict_terminate.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict_terminate.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"tflite_semantic_predict_initialize.cpp.dep" -MT"tflite_semantic_predict_initialize.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict_initialize.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict_initialize.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"invokeinterpreter.cpp.dep" -MT"invokeinterpreter.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "invokeinterpreter.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/invokeinterpreter.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"tflite_semantic_predict.cpp.dep" -MT"tflite_semantic_predict.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
————————————————————————
Build error: C++ compiler produced errors. See the Build Log for further details.
More information
Code generation failed: View Error Report
Error using codegen
Thank you so much i have tried to download the flatbuffers by CMake and bazel but i had no luck since they are 64 bit codes and mine is a 32bit aarch64.Good afternoon,
I have been trying to deploy a tflite model onto my raspberry pi using MATLAB 2024a.
To start i am using:
Example code (SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample).
Mex code setup i am using ‘Microsoft Visual C++ 2022’
Built Tensorflow 2.15 on Windows with Bazel 6.10
Downloaded and setup Raspberry pi Matlab config
Raspberry pi 32 bit bullseye (python 3.9.2)
created all of the paths accordingly as stated in Prerequisites for Deep Learning with TensorFlow Lite Models
When i run the code it has no errors. The problem starts once i run:
codegen -config cfg tflite_semantic_predict -args ones(257,257,3,’single’)
The error is as follows:
codegen -config cfg tflite_semantic_predict -args ones(257,257,3,’single’)
————————————————————————
Error executing command "touch -c /home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/*.*;make -j$(($(nproc)+1)) -Otarget -f tflite_semantic_predict_rtw.mk all MATLAB_WORKSPACE="/home/bmblaylock42/MATLAB_ws/R2024a" LINUX_TARGET_LIBS_MACRO="" -C /home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict LC_ALL=C". Details:
STDERR: In file included from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/model.h:26,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/kernels/register.h:22,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/kernels/register.h:18,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/invokeinterpreter.hpp:16,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/invokeinterpreter.cpp:6:
/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/interpreter_builder.h:33:10: fatal error: flatbuffers/flatbuffers.h: No such file or directory
33 | #include "flatbuffers/flatbuffers.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [tflite_semantic_predict_rtw.mk:382: invokeinterpreter.cpp.o] Error 1
make: *** Waiting for unfinished jobs….
In file included from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/model.h:26,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/kernels/register.h:22,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/kernels/register.h:18,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/invokeinterpreter.hpp:16,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict.cpp:15:
/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/interpreter_builder.h:33:10: fatal error: flatbuffers/flatbuffers.h: No such file or directory
33 | #include "flatbuffers/flatbuffers.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [tflite_semantic_predict_rtw.mk:398: tflite_semantic_predict.cpp.o] Error 1
STDOUT: make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"tflite_semantic_predict_data.cpp.dep" -MT"tflite_semantic_predict_data.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict_data.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict_data.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"tflite_semantic_predict_terminate.cpp.dep" -MT"tflite_semantic_predict_terminate.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict_terminate.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict_terminate.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"tflite_semantic_predict_initialize.cpp.dep" -MT"tflite_semantic_predict_initialize.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict_initialize.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict_initialize.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"invokeinterpreter.cpp.dep" -MT"invokeinterpreter.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "invokeinterpreter.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/invokeinterpreter.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"tflite_semantic_predict.cpp.dep" -MT"tflite_semantic_predict.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
————————————————————————
Build error: C++ compiler produced errors. See the Build Log for further details.
More information
Code generation failed: View Error Report
Error using codegen
Thank you so much i have tried to download the flatbuffers by CMake and bazel but i had no luck since they are 64 bit codes and mine is a 32bit aarch64. Good afternoon,
I have been trying to deploy a tflite model onto my raspberry pi using MATLAB 2024a.
To start i am using:
Example code (SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample).
Mex code setup i am using ‘Microsoft Visual C++ 2022’
Built Tensorflow 2.15 on Windows with Bazel 6.10
Downloaded and setup Raspberry pi Matlab config
Raspberry pi 32 bit bullseye (python 3.9.2)
created all of the paths accordingly as stated in Prerequisites for Deep Learning with TensorFlow Lite Models
When i run the code it has no errors. The problem starts once i run:
codegen -config cfg tflite_semantic_predict -args ones(257,257,3,’single’)
The error is as follows:
codegen -config cfg tflite_semantic_predict -args ones(257,257,3,’single’)
————————————————————————
Error executing command "touch -c /home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/*.*;make -j$(($(nproc)+1)) -Otarget -f tflite_semantic_predict_rtw.mk all MATLAB_WORKSPACE="/home/bmblaylock42/MATLAB_ws/R2024a" LINUX_TARGET_LIBS_MACRO="" -C /home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict LC_ALL=C". Details:
STDERR: In file included from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/model.h:26,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/kernels/register.h:22,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/kernels/register.h:18,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/invokeinterpreter.hpp:16,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/invokeinterpreter.cpp:6:
/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/interpreter_builder.h:33:10: fatal error: flatbuffers/flatbuffers.h: No such file or directory
33 | #include "flatbuffers/flatbuffers.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [tflite_semantic_predict_rtw.mk:382: invokeinterpreter.cpp.o] Error 1
make: *** Waiting for unfinished jobs….
In file included from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/model.h:26,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/kernels/register.h:22,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/kernels/register.h:18,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/invokeinterpreter.hpp:16,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict.cpp:15:
/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/interpreter_builder.h:33:10: fatal error: flatbuffers/flatbuffers.h: No such file or directory
33 | #include "flatbuffers/flatbuffers.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [tflite_semantic_predict_rtw.mk:398: tflite_semantic_predict.cpp.o] Error 1
STDOUT: make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"tflite_semantic_predict_data.cpp.dep" -MT"tflite_semantic_predict_data.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict_data.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict_data.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"tflite_semantic_predict_terminate.cpp.dep" -MT"tflite_semantic_predict_terminate.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict_terminate.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict_terminate.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"tflite_semantic_predict_initialize.cpp.dep" -MT"tflite_semantic_predict_initialize.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict_initialize.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict_initialize.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"invokeinterpreter.cpp.dep" -MT"invokeinterpreter.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "invokeinterpreter.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/invokeinterpreter.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
make: Entering directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
g++ -c -MMD -MP -MF"tflite_semantic_predict.cpp.dep" -MT"tflite_semantic_predict.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict.cpp"
make: Leaving directory ‘/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict’
————————————————————————
Build error: C++ compiler produced errors. See the Build Log for further details.
More information
Code generation failed: View Error Report
Error using codegen
Thank you so much i have tried to download the flatbuffers by CMake and bazel but i had no luck since they are 64 bit codes and mine is a 32bit aarch64. tensorflow, matlab, code generation MATLAB Answers — New Questions
why is my loop printing 0 instead of a value, not sure which part of the code is incorrect
right now the code is at an increment of 15 to test, but the final incremment will be 0.01
code needs to have an if statement within the while loop.
%range is the maximum achievable horizontal distance
% range angle is the angle that yields the maximum horizontaal distance
% use a whilel loop with a nested if statement to compute the maximum
% landing distance (range) ange the angle corrsesponding to the maximum
% landing distance (rangle angle) of the ME En 1010 ping pong cannon
function [range, rangeAngle] = ProjectileRange(d1, d2, v0)
thetaL = 90;
range = 0;
rangeAngle = 0;
[xLand] = LandingDistance(d1, d2, v0, thetaL);
while thetaL <= 90;
if xLand > range
range = xLand
rangeAngle = thetaL
end
thetaL = thetaL + 15;
end
end
%% test
d1 = 0.0876;
d2 = 0.1190;
v0 = 3.2;
[range, rangeAngle] = ProjectileRange(d1, d2, v0);
fprintf(‘The range is %.2f m at a launch angle of %.2f degrees’, range, rangeAngle)
this is what it prints:
The range is 0.00 m at a launch angle of 0.00 degrees>>
I need it to print "the range is 1.29 m at a launch angle of 41.6 degrees" when it has an incrememnt of 0.01right now the code is at an increment of 15 to test, but the final incremment will be 0.01
code needs to have an if statement within the while loop.
%range is the maximum achievable horizontal distance
% range angle is the angle that yields the maximum horizontaal distance
% use a whilel loop with a nested if statement to compute the maximum
% landing distance (range) ange the angle corrsesponding to the maximum
% landing distance (rangle angle) of the ME En 1010 ping pong cannon
function [range, rangeAngle] = ProjectileRange(d1, d2, v0)
thetaL = 90;
range = 0;
rangeAngle = 0;
[xLand] = LandingDistance(d1, d2, v0, thetaL);
while thetaL <= 90;
if xLand > range
range = xLand
rangeAngle = thetaL
end
thetaL = thetaL + 15;
end
end
%% test
d1 = 0.0876;
d2 = 0.1190;
v0 = 3.2;
[range, rangeAngle] = ProjectileRange(d1, d2, v0);
fprintf(‘The range is %.2f m at a launch angle of %.2f degrees’, range, rangeAngle)
this is what it prints:
The range is 0.00 m at a launch angle of 0.00 degrees>>
I need it to print "the range is 1.29 m at a launch angle of 41.6 degrees" when it has an incrememnt of 0.01 right now the code is at an increment of 15 to test, but the final incremment will be 0.01
code needs to have an if statement within the while loop.
%range is the maximum achievable horizontal distance
% range angle is the angle that yields the maximum horizontaal distance
% use a whilel loop with a nested if statement to compute the maximum
% landing distance (range) ange the angle corrsesponding to the maximum
% landing distance (rangle angle) of the ME En 1010 ping pong cannon
function [range, rangeAngle] = ProjectileRange(d1, d2, v0)
thetaL = 90;
range = 0;
rangeAngle = 0;
[xLand] = LandingDistance(d1, d2, v0, thetaL);
while thetaL <= 90;
if xLand > range
range = xLand
rangeAngle = thetaL
end
thetaL = thetaL + 15;
end
end
%% test
d1 = 0.0876;
d2 = 0.1190;
v0 = 3.2;
[range, rangeAngle] = ProjectileRange(d1, d2, v0);
fprintf(‘The range is %.2f m at a launch angle of %.2f degrees’, range, rangeAngle)
this is what it prints:
The range is 0.00 m at a launch angle of 0.00 degrees>>
I need it to print "the range is 1.29 m at a launch angle of 41.6 degrees" when it has an incrememnt of 0.01 while/if loop, answer is 0 when it should be a value MATLAB Answers — New Questions
HMM Training for estimating transition and emission matrices
Hi all, I am trying to use the hmmtrain to learn the emission (emis) and transition (trans) matrices for a power dataset in dBm and subsequently generate data based on the emis and trans generated.
For now, I have discretized the noise power values, using integers to represent each bin of power values and to generate a sequence of emissions (seq) based on the discretized values. But after implementing the hmmtrain to generate an estimated trans and emis that depicts seq, I am unable to generate similar seqs using the estimated trans and emis (using hmmgenerate). In the sequence of states, hmmgenerate basically produces very few outcomes depicting state 1 leaving the rest in state 2. This does not correspond with my dataset which is about 800 and comprised of a whole lot more of state 1 outcomes than the model depicts. I need help/advice with this please.Hi all, I am trying to use the hmmtrain to learn the emission (emis) and transition (trans) matrices for a power dataset in dBm and subsequently generate data based on the emis and trans generated.
For now, I have discretized the noise power values, using integers to represent each bin of power values and to generate a sequence of emissions (seq) based on the discretized values. But after implementing the hmmtrain to generate an estimated trans and emis that depicts seq, I am unable to generate similar seqs using the estimated trans and emis (using hmmgenerate). In the sequence of states, hmmgenerate basically produces very few outcomes depicting state 1 leaving the rest in state 2. This does not correspond with my dataset which is about 800 and comprised of a whole lot more of state 1 outcomes than the model depicts. I need help/advice with this please. Hi all, I am trying to use the hmmtrain to learn the emission (emis) and transition (trans) matrices for a power dataset in dBm and subsequently generate data based on the emis and trans generated.
For now, I have discretized the noise power values, using integers to represent each bin of power values and to generate a sequence of emissions (seq) based on the discretized values. But after implementing the hmmtrain to generate an estimated trans and emis that depicts seq, I am unable to generate similar seqs using the estimated trans and emis (using hmmgenerate). In the sequence of states, hmmgenerate basically produces very few outcomes depicting state 1 leaving the rest in state 2. This does not correspond with my dataset which is about 800 and comprised of a whole lot more of state 1 outcomes than the model depicts. I need help/advice with this please. hmmtrain, hmmgenerate, impulsive noise MATLAB Answers — New Questions
Error generating MEX PIL due to missing header file for deployment of TFLite model to Raspberry Pi
Hi!
I am encountering a problem when I am trying to deploy a TFLite mode for semantic segmentation on Raspberry Pi. I was following this example by following openExample(‘deeplearning_shared/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample’)
Before running this example, I have installed the TFLite library on both the local Windows computer directly under "C:tensorflow-2.15.0" following this link:
https://www.mathworks.com/matlabcentral/answers/1631265-matlab-coder-how-do-i-build-tensorflow-lite-for-deep-learning-c-code-generation-and-deployment
and Raspberry Pi 4b (buster; 32bit OS) under "/home/pi/tensorflow/tensorflow/" following this:
https://qengineering.eu/install-tensorflow-2-lite-on-raspberry-pi-4.html
Additionally, the environment variables are set on both the local and raspi machines according to:
https://www.mathworks.com/help/deeplearning/ug/prerequisites-for-deep-learning-with-tensorflow-lite-models.html
While I had no problem with generating the MEX file on the local Windows computer with this section of codes in the example:
cfg = coder.config(‘mex’);
cfg.TargetLang = ‘C++’;
codegen -config cfg tflite_semantic_predict -args ones(257, 257,3,’single’)
I encountered errors when I tried to generate the MEX PIL function through
cfg = coder.config(‘lib’,’ecoder’,true);
cfg.TargetLang = ‘C++’;
cfg.VerificationMode = ‘PIL’;
hw = coder.hardware(‘Raspberry Pi’);
cfg.Hardware = hw;
codegen -config cfg tflite_semantic_predict -args ones(257,257,3,’single’)
I have attached the entire error message in the txt file. Part of the error message reads:
fatal error: kernels/register.h: No such file or directory
#include "kernels/register.h"
However, when I searched the directories indicated by the environment variables, I could find the kernels/register.h file on both the Windows and RPi machines under the PATH (in Windows) or LD_LIBRARY_PATH (in RPi) variables. Please see the attached screenshots.
Here is how I set the environmental variables. On RPI, I executed:
export TFLITE_PATH="/home/pi/tensorflow/tensorflow"
export LD_LIBRARY_PATH="/home/pi/tensorflow/tensorflow/tensorflow/lite"
export TFLITE_MODEL_PATH="/home/pi"
and on Windows, I directly edited the environmental variable TFLITE_PATH and amended Path variable.
I’d appreciate any advice on how to resolve this missing header file issue by MATLAB coder.
Thank you all!Hi!
I am encountering a problem when I am trying to deploy a TFLite mode for semantic segmentation on Raspberry Pi. I was following this example by following openExample(‘deeplearning_shared/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample’)
Before running this example, I have installed the TFLite library on both the local Windows computer directly under "C:tensorflow-2.15.0" following this link:
https://www.mathworks.com/matlabcentral/answers/1631265-matlab-coder-how-do-i-build-tensorflow-lite-for-deep-learning-c-code-generation-and-deployment
and Raspberry Pi 4b (buster; 32bit OS) under "/home/pi/tensorflow/tensorflow/" following this:
https://qengineering.eu/install-tensorflow-2-lite-on-raspberry-pi-4.html
Additionally, the environment variables are set on both the local and raspi machines according to:
https://www.mathworks.com/help/deeplearning/ug/prerequisites-for-deep-learning-with-tensorflow-lite-models.html
While I had no problem with generating the MEX file on the local Windows computer with this section of codes in the example:
cfg = coder.config(‘mex’);
cfg.TargetLang = ‘C++’;
codegen -config cfg tflite_semantic_predict -args ones(257, 257,3,’single’)
I encountered errors when I tried to generate the MEX PIL function through
cfg = coder.config(‘lib’,’ecoder’,true);
cfg.TargetLang = ‘C++’;
cfg.VerificationMode = ‘PIL’;
hw = coder.hardware(‘Raspberry Pi’);
cfg.Hardware = hw;
codegen -config cfg tflite_semantic_predict -args ones(257,257,3,’single’)
I have attached the entire error message in the txt file. Part of the error message reads:
fatal error: kernels/register.h: No such file or directory
#include "kernels/register.h"
However, when I searched the directories indicated by the environment variables, I could find the kernels/register.h file on both the Windows and RPi machines under the PATH (in Windows) or LD_LIBRARY_PATH (in RPi) variables. Please see the attached screenshots.
Here is how I set the environmental variables. On RPI, I executed:
export TFLITE_PATH="/home/pi/tensorflow/tensorflow"
export LD_LIBRARY_PATH="/home/pi/tensorflow/tensorflow/tensorflow/lite"
export TFLITE_MODEL_PATH="/home/pi"
and on Windows, I directly edited the environmental variable TFLITE_PATH and amended Path variable.
I’d appreciate any advice on how to resolve this missing header file issue by MATLAB coder.
Thank you all! Hi!
I am encountering a problem when I am trying to deploy a TFLite mode for semantic segmentation on Raspberry Pi. I was following this example by following openExample(‘deeplearning_shared/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample’)
Before running this example, I have installed the TFLite library on both the local Windows computer directly under "C:tensorflow-2.15.0" following this link:
https://www.mathworks.com/matlabcentral/answers/1631265-matlab-coder-how-do-i-build-tensorflow-lite-for-deep-learning-c-code-generation-and-deployment
and Raspberry Pi 4b (buster; 32bit OS) under "/home/pi/tensorflow/tensorflow/" following this:
https://qengineering.eu/install-tensorflow-2-lite-on-raspberry-pi-4.html
Additionally, the environment variables are set on both the local and raspi machines according to:
https://www.mathworks.com/help/deeplearning/ug/prerequisites-for-deep-learning-with-tensorflow-lite-models.html
While I had no problem with generating the MEX file on the local Windows computer with this section of codes in the example:
cfg = coder.config(‘mex’);
cfg.TargetLang = ‘C++’;
codegen -config cfg tflite_semantic_predict -args ones(257, 257,3,’single’)
I encountered errors when I tried to generate the MEX PIL function through
cfg = coder.config(‘lib’,’ecoder’,true);
cfg.TargetLang = ‘C++’;
cfg.VerificationMode = ‘PIL’;
hw = coder.hardware(‘Raspberry Pi’);
cfg.Hardware = hw;
codegen -config cfg tflite_semantic_predict -args ones(257,257,3,’single’)
I have attached the entire error message in the txt file. Part of the error message reads:
fatal error: kernels/register.h: No such file or directory
#include "kernels/register.h"
However, when I searched the directories indicated by the environment variables, I could find the kernels/register.h file on both the Windows and RPi machines under the PATH (in Windows) or LD_LIBRARY_PATH (in RPi) variables. Please see the attached screenshots.
Here is how I set the environmental variables. On RPI, I executed:
export TFLITE_PATH="/home/pi/tensorflow/tensorflow"
export LD_LIBRARY_PATH="/home/pi/tensorflow/tensorflow/tensorflow/lite"
export TFLITE_MODEL_PATH="/home/pi"
and on Windows, I directly edited the environmental variable TFLITE_PATH and amended Path variable.
I’d appreciate any advice on how to resolve this missing header file issue by MATLAB coder.
Thank you all! tflite, raspberry pi, deploy, semantic segmentation MATLAB Answers — New Questions
Subdivide a figure window into two rows and one column?
I am trying to use the subplot command for class and I’m not sure if the plot is displaying properly based on the code I am writing.
% 1) Subdivide a figure window into two rows and one column.
subplot(5,4,2)I am trying to use the subplot command for class and I’m not sure if the plot is displaying properly based on the code I am writing.
% 1) Subdivide a figure window into two rows and one column.
subplot(5,4,2) I am trying to use the subplot command for class and I’m not sure if the plot is displaying properly based on the code I am writing.
% 1) Subdivide a figure window into two rows and one column.
subplot(5,4,2) subplot MATLAB Answers — New Questions
I am calling outside functions for this code, but when I am getting an error saying I have too many output arguments. I think the error is within my function LandingDistance
%% problem 2
% user-defined function to compute the horizontal distance
% traveled by a projectile knowing the launch angle, the initial velocity,
% and geometric parameters defining the initial coordinates of the projectile.
d1 = 0.0876;
d2 = 0.1190;
v0 = 3.2;
thetaL = 50;
g = 9.81; % gravitational acceleration in m/s^2
% call initial coords function and initial velocity function
[x0, y0] = InitialCoords(d1, d2, thetaL); % input units: m, m, degrees, output units: m
[v0x, v0y] = InitialVelocityComponents(v0, thetaL); % input units: m/s de,grees, output units: m/s
%Solve the y equation for tLand by calling your Quadratic function.
a = -0.5*g; % g = acceleration due to gravity in m/s^2
b = v0y; % initial velocity in y direction
c = y0; % initial y position
plusOrMinus = -1;
root = Quadratic(a, b, c, plusOrMinus); % neg root
tLand = root;
% plug tLand into the x eqn to get xLand
xLand = LandingDistance(d1, d2, v0, thetaL);
fprintf(‘For launch angle = %.1f degrees and v0 = %.1f m/s, the landing distance is %.2f m n’, thetaL, v0, xLand)
Error using LandingDistance
Too many output arguments.
Error in HW3_projectile (line 36)
xLand = LandingDistance(d1, d2, v0, thetaL);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_____________________________________
function code
% landing distance function
function LandingDistance(d1, d2, v0, thetaL)
% x_Land –> the horizontal distance traveled by the projectile
g = 9.81; % gravitational acceleration in m/s^2
[x0, y0] = InitialCoords(d1, d2, thetaL) % input units: m, m, degrees, output units: m
[v0x, v0y] = InitialVelocityComponents(v0, thetaL) % input units: m/s de,grees, output units: m/s
a = -0.5*g; % g = acceleration due to gravity in m/s^2
b = v0y; % initial velocity in y direction
c = y0; % initial y position
plusOrMinus = -1;
[root] = Quadratic(a, b, c, plusOrMinus); % neg root
tLand = root
xLand = x0 + (v0x*tLand)
end
Not enough input arguments.
Error in LandingDistance (line 6)
[x0, y0] = InitialCoords(d1, d2, thetaL)
^^
>>%% problem 2
% user-defined function to compute the horizontal distance
% traveled by a projectile knowing the launch angle, the initial velocity,
% and geometric parameters defining the initial coordinates of the projectile.
d1 = 0.0876;
d2 = 0.1190;
v0 = 3.2;
thetaL = 50;
g = 9.81; % gravitational acceleration in m/s^2
% call initial coords function and initial velocity function
[x0, y0] = InitialCoords(d1, d2, thetaL); % input units: m, m, degrees, output units: m
[v0x, v0y] = InitialVelocityComponents(v0, thetaL); % input units: m/s de,grees, output units: m/s
%Solve the y equation for tLand by calling your Quadratic function.
a = -0.5*g; % g = acceleration due to gravity in m/s^2
b = v0y; % initial velocity in y direction
c = y0; % initial y position
plusOrMinus = -1;
root = Quadratic(a, b, c, plusOrMinus); % neg root
tLand = root;
% plug tLand into the x eqn to get xLand
xLand = LandingDistance(d1, d2, v0, thetaL);
fprintf(‘For launch angle = %.1f degrees and v0 = %.1f m/s, the landing distance is %.2f m n’, thetaL, v0, xLand)
Error using LandingDistance
Too many output arguments.
Error in HW3_projectile (line 36)
xLand = LandingDistance(d1, d2, v0, thetaL);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_____________________________________
function code
% landing distance function
function LandingDistance(d1, d2, v0, thetaL)
% x_Land –> the horizontal distance traveled by the projectile
g = 9.81; % gravitational acceleration in m/s^2
[x0, y0] = InitialCoords(d1, d2, thetaL) % input units: m, m, degrees, output units: m
[v0x, v0y] = InitialVelocityComponents(v0, thetaL) % input units: m/s de,grees, output units: m/s
a = -0.5*g; % g = acceleration due to gravity in m/s^2
b = v0y; % initial velocity in y direction
c = y0; % initial y position
plusOrMinus = -1;
[root] = Quadratic(a, b, c, plusOrMinus); % neg root
tLand = root
xLand = x0 + (v0x*tLand)
end
Not enough input arguments.
Error in LandingDistance (line 6)
[x0, y0] = InitialCoords(d1, d2, thetaL)
^^
>> %% problem 2
% user-defined function to compute the horizontal distance
% traveled by a projectile knowing the launch angle, the initial velocity,
% and geometric parameters defining the initial coordinates of the projectile.
d1 = 0.0876;
d2 = 0.1190;
v0 = 3.2;
thetaL = 50;
g = 9.81; % gravitational acceleration in m/s^2
% call initial coords function and initial velocity function
[x0, y0] = InitialCoords(d1, d2, thetaL); % input units: m, m, degrees, output units: m
[v0x, v0y] = InitialVelocityComponents(v0, thetaL); % input units: m/s de,grees, output units: m/s
%Solve the y equation for tLand by calling your Quadratic function.
a = -0.5*g; % g = acceleration due to gravity in m/s^2
b = v0y; % initial velocity in y direction
c = y0; % initial y position
plusOrMinus = -1;
root = Quadratic(a, b, c, plusOrMinus); % neg root
tLand = root;
% plug tLand into the x eqn to get xLand
xLand = LandingDistance(d1, d2, v0, thetaL);
fprintf(‘For launch angle = %.1f degrees and v0 = %.1f m/s, the landing distance is %.2f m n’, thetaL, v0, xLand)
Error using LandingDistance
Too many output arguments.
Error in HW3_projectile (line 36)
xLand = LandingDistance(d1, d2, v0, thetaL);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_____________________________________
function code
% landing distance function
function LandingDistance(d1, d2, v0, thetaL)
% x_Land –> the horizontal distance traveled by the projectile
g = 9.81; % gravitational acceleration in m/s^2
[x0, y0] = InitialCoords(d1, d2, thetaL) % input units: m, m, degrees, output units: m
[v0x, v0y] = InitialVelocityComponents(v0, thetaL) % input units: m/s de,grees, output units: m/s
a = -0.5*g; % g = acceleration due to gravity in m/s^2
b = v0y; % initial velocity in y direction
c = y0; % initial y position
plusOrMinus = -1;
[root] = Quadratic(a, b, c, plusOrMinus); % neg root
tLand = root
xLand = x0 + (v0x*tLand)
end
Not enough input arguments.
Error in LandingDistance (line 6)
[x0, y0] = InitialCoords(d1, d2, thetaL)
^^
>> error, not enough inputs, too many outputs MATLAB Answers — New Questions
Problem with Code for my coursera course
This is the question I am trying to solve and I also uploading the code i have written and error I am getting, Please help me the error please.This is the question I am trying to solve and I also uploading the code i have written and error I am getting, Please help me the error please. This is the question I am trying to solve and I also uploading the code i have written and error I am getting, Please help me the error please. code, problem, urgent MATLAB Answers — New Questions
Intel vs AMD for a new build in 2025
Hello everyone,
I’m planning a new PC build and am currently undecided about which CPU to choose.
I understand that AMD CPUs have faced some slower performance in MATLAB due to Intel MKL but I understand it was solved with the AMD AOCL? Bench instruction results also seem to show a performance difference between Intel and AMD CPUs (but couldn’t check too many).
Intel CPUs seem to have some issues which probably have been solved for 14th gen with the new BIOS updates, and 15th gen is not quite mature. Their power dissipation is quite high.
For MATLAB, I plan to use the Parallel Computing and Optimization Toolboxes. Apart from MATLAB, ANSYS or other FEA software will be the most demanding applications, and I also plan to game from time to time.
I will pair this with an RTX3070 for the moment.
I was looking at the following CPUs:
Intel Ultra 7 265k – $230 / $600
Intel I9 14900k – $390 / $650
AMD Ryzen 7 9800x3D – $474 / $750
AMD Ryzen 7 9950X – $570 /$910
(Prices listed are current and include discounts, with $ CPU / $ CPU+Mobo+RAM)
Thank you!Hello everyone,
I’m planning a new PC build and am currently undecided about which CPU to choose.
I understand that AMD CPUs have faced some slower performance in MATLAB due to Intel MKL but I understand it was solved with the AMD AOCL? Bench instruction results also seem to show a performance difference between Intel and AMD CPUs (but couldn’t check too many).
Intel CPUs seem to have some issues which probably have been solved for 14th gen with the new BIOS updates, and 15th gen is not quite mature. Their power dissipation is quite high.
For MATLAB, I plan to use the Parallel Computing and Optimization Toolboxes. Apart from MATLAB, ANSYS or other FEA software will be the most demanding applications, and I also plan to game from time to time.
I will pair this with an RTX3070 for the moment.
I was looking at the following CPUs:
Intel Ultra 7 265k – $230 / $600
Intel I9 14900k – $390 / $650
AMD Ryzen 7 9800x3D – $474 / $750
AMD Ryzen 7 9950X – $570 /$910
(Prices listed are current and include discounts, with $ CPU / $ CPU+Mobo+RAM)
Thank you! Hello everyone,
I’m planning a new PC build and am currently undecided about which CPU to choose.
I understand that AMD CPUs have faced some slower performance in MATLAB due to Intel MKL but I understand it was solved with the AMD AOCL? Bench instruction results also seem to show a performance difference between Intel and AMD CPUs (but couldn’t check too many).
Intel CPUs seem to have some issues which probably have been solved for 14th gen with the new BIOS updates, and 15th gen is not quite mature. Their power dissipation is quite high.
For MATLAB, I plan to use the Parallel Computing and Optimization Toolboxes. Apart from MATLAB, ANSYS or other FEA software will be the most demanding applications, and I also plan to game from time to time.
I will pair this with an RTX3070 for the moment.
I was looking at the following CPUs:
Intel Ultra 7 265k – $230 / $600
Intel I9 14900k – $390 / $650
AMD Ryzen 7 9800x3D – $474 / $750
AMD Ryzen 7 9950X – $570 /$910
(Prices listed are current and include discounts, with $ CPU / $ CPU+Mobo+RAM)
Thank you! parallel computing toolbox, optimization, pc build, intel vs amd, cpu MATLAB Answers — New Questions
The mesh function is not working for me in offline Matlab, but when I check this code in online Matlab, it works. What is the reason?
Post Content Post Content mesh, surf MATLAB Answers — New Questions
Simulink dashboard button matching
I’m looking for suggestions on how to approach a Simulink interface problem.
In case 1 below, both dashboard buttons have connections to constant S1 such that if you change either button, the other button will track.
In case 2 I’m looking to do something similar but with a constant and a button. If I entered 0b0 for desired state, then S2 would change to zero, and the button would shift to A. If I moved the button to B, then S2 would change back to 1, and Desired State would also change to 0b1.
This is a simplified test case of a more complex scenario I want to work up, where there is one binary input (e.g. 0b01010), and 5 buttons, and 5 constants.
In one direction, I could use a matlab function to call set_param if the binary input is changed to set the value of S2. But I am unsure about the other direction.I’m looking for suggestions on how to approach a Simulink interface problem.
In case 1 below, both dashboard buttons have connections to constant S1 such that if you change either button, the other button will track.
In case 2 I’m looking to do something similar but with a constant and a button. If I entered 0b0 for desired state, then S2 would change to zero, and the button would shift to A. If I moved the button to B, then S2 would change back to 1, and Desired State would also change to 0b1.
This is a simplified test case of a more complex scenario I want to work up, where there is one binary input (e.g. 0b01010), and 5 buttons, and 5 constants.
In one direction, I could use a matlab function to call set_param if the binary input is changed to set the value of S2. But I am unsure about the other direction. I’m looking for suggestions on how to approach a Simulink interface problem.
In case 1 below, both dashboard buttons have connections to constant S1 such that if you change either button, the other button will track.
In case 2 I’m looking to do something similar but with a constant and a button. If I entered 0b0 for desired state, then S2 would change to zero, and the button would shift to A. If I moved the button to B, then S2 would change back to 1, and Desired State would also change to 0b1.
This is a simplified test case of a more complex scenario I want to work up, where there is one binary input (e.g. 0b01010), and 5 buttons, and 5 constants.
In one direction, I could use a matlab function to call set_param if the binary input is changed to set the value of S2. But I am unsure about the other direction. simulink, dashboard, buttons, interface MATLAB Answers — New Questions
Spectrum analyser can’t plot the whole frequency-time spain
Hi there,
i try to use Spectrum Analyzer to plot the signal, which benn calculated by Short-time Fourier Transform.
However, i can’t see the whole plot in Spectrum Analyzer, that is, it should show from 0~15s, but actually it only shows 14~15s.Hi there,
i try to use Spectrum Analyzer to plot the signal, which benn calculated by Short-time Fourier Transform.
However, i can’t see the whole plot in Spectrum Analyzer, that is, it should show from 0~15s, but actually it only shows 14~15s. Hi there,
i try to use Spectrum Analyzer to plot the signal, which benn calculated by Short-time Fourier Transform.
However, i can’t see the whole plot in Spectrum Analyzer, that is, it should show from 0~15s, but actually it only shows 14~15s. fft, simulink MATLAB Answers — New Questions
MATLAB doesn’t recognize the function optimoptions
I’m getting an error at the following line:
options = optimoptions(‘ga’,’PopulationSize’,10,’MaxGenerations’,10);
The following message exemplifies the problem.
I’m using the version 9.10 (R2021a) of MATLAB and the version 4.5 (R2021a) of the Global Optimization Toolbox
Any suggestions will be appreciatedI’m getting an error at the following line:
options = optimoptions(‘ga’,’PopulationSize’,10,’MaxGenerations’,10);
The following message exemplifies the problem.
I’m using the version 9.10 (R2021a) of MATLAB and the version 4.5 (R2021a) of the Global Optimization Toolbox
Any suggestions will be appreciated I’m getting an error at the following line:
options = optimoptions(‘ga’,’PopulationSize’,10,’MaxGenerations’,10);
The following message exemplifies the problem.
I’m using the version 9.10 (R2021a) of MATLAB and the version 4.5 (R2021a) of the Global Optimization Toolbox
Any suggestions will be appreciated #unrecognized, optimoptions, #ga MATLAB Answers — New Questions
I am trying to edit an old code to simplify it but I keep getting errors. Right now I am getting the script name error even though I have followed instructions fo rnaming
I get the error saying i can’t have the same script name as the function but it worked before and I haven’t changed the name
%% problem 1c – projectile Quadratic
function [root] = Quadratic(a, b, c, plusOrMinus)
% Quadratic – determine the root of the projectile using the quadratic equation
% a, b, and c are the coefficients of the quadratic equation, plusOrMinus
% is a multiplier (+1 or -1) that selects the + or – in the quadratic
% formula. root is a single root of the quadratic equation that is
% computed using the quadratic formula.
% Erin Gibbs, u1556567, ME EN 1010, HW#2
root = (-b + plusOrMinus * (sqrt(b^2 – (4*a*c)))) / (2 * a);
end
%% test case 1 (positive plusOrMinus)
% equation: x^2 – x – 2 = 0
a = 1;
b = -1;
c = -2;
plusOrMinus = 1;
[root] = Quadratic(a, b, c, plusOrMinus)I get the error saying i can’t have the same script name as the function but it worked before and I haven’t changed the name
%% problem 1c – projectile Quadratic
function [root] = Quadratic(a, b, c, plusOrMinus)
% Quadratic – determine the root of the projectile using the quadratic equation
% a, b, and c are the coefficients of the quadratic equation, plusOrMinus
% is a multiplier (+1 or -1) that selects the + or – in the quadratic
% formula. root is a single root of the quadratic equation that is
% computed using the quadratic formula.
% Erin Gibbs, u1556567, ME EN 1010, HW#2
root = (-b + plusOrMinus * (sqrt(b^2 – (4*a*c)))) / (2 * a);
end
%% test case 1 (positive plusOrMinus)
% equation: x^2 – x – 2 = 0
a = 1;
b = -1;
c = -2;
plusOrMinus = 1;
[root] = Quadratic(a, b, c, plusOrMinus) I get the error saying i can’t have the same script name as the function but it worked before and I haven’t changed the name
%% problem 1c – projectile Quadratic
function [root] = Quadratic(a, b, c, plusOrMinus)
% Quadratic – determine the root of the projectile using the quadratic equation
% a, b, and c are the coefficients of the quadratic equation, plusOrMinus
% is a multiplier (+1 or -1) that selects the + or – in the quadratic
% formula. root is a single root of the quadratic equation that is
% computed using the quadratic formula.
% Erin Gibbs, u1556567, ME EN 1010, HW#2
root = (-b + plusOrMinus * (sqrt(b^2 – (4*a*c)))) / (2 * a);
end
%% test case 1 (positive plusOrMinus)
% equation: x^2 – x – 2 = 0
a = 1;
b = -1;
c = -2;
plusOrMinus = 1;
[root] = Quadratic(a, b, c, plusOrMinus) arduino, function, script name MATLAB Answers — New Questions
PC specs for heavy & complex simulations
Hello everone,
I have a complex model which takes very long time to be built, too much time in simulation & may cause MATLAB to crash.
In my last trial, the CPU load was around 89% & memory usage was 90%.
I want to know what specs should I have to simulate large & complex model easily without heavy loading & taking much time, my currently specs are: CPU: 13th Gen Intel® Core™ i5-1335U 1.3 GHz // RAM: 16 GB DDR4 3200 MHz // GPU: Intel® Iris® Xe Graphics Family.Hello everone,
I have a complex model which takes very long time to be built, too much time in simulation & may cause MATLAB to crash.
In my last trial, the CPU load was around 89% & memory usage was 90%.
I want to know what specs should I have to simulate large & complex model easily without heavy loading & taking much time, my currently specs are: CPU: 13th Gen Intel® Core™ i5-1335U 1.3 GHz // RAM: 16 GB DDR4 3200 MHz // GPU: Intel® Iris® Xe Graphics Family. Hello everone,
I have a complex model which takes very long time to be built, too much time in simulation & may cause MATLAB to crash.
In my last trial, the CPU load was around 89% & memory usage was 90%.
I want to know what specs should I have to simulate large & complex model easily without heavy loading & taking much time, my currently specs are: CPU: 13th Gen Intel® Core™ i5-1335U 1.3 GHz // RAM: 16 GB DDR4 3200 MHz // GPU: Intel® Iris® Xe Graphics Family. simulation, simulink, matlab, specs, cpu load, model, complex MATLAB Answers — New Questions
Thingspeak update with error code 211 from Arduinos
Hello, I have been encountering several times a day for a few weeks an error when updating my data stored on Thingspeak (computerized hive parameters).
The return code of my Arduinos is 211!
But I can’t find the meaning of this code anywhere…
Does anyone know more?
Here is one of my hives: https://thingspeak.mathworks.com/channels/1289244
Thanks
PS: The update continues to be done but it seems to be missing points (those that return the error 211)Hello, I have been encountering several times a day for a few weeks an error when updating my data stored on Thingspeak (computerized hive parameters).
The return code of my Arduinos is 211!
But I can’t find the meaning of this code anywhere…
Does anyone know more?
Here is one of my hives: https://thingspeak.mathworks.com/channels/1289244
Thanks
PS: The update continues to be done but it seems to be missing points (those that return the error 211) Hello, I have been encountering several times a day for a few weeks an error when updating my data stored on Thingspeak (computerized hive parameters).
The return code of my Arduinos is 211!
But I can’t find the meaning of this code anywhere…
Does anyone know more?
Here is one of my hives: https://thingspeak.mathworks.com/channels/1289244
Thanks
PS: The update continues to be done but it seems to be missing points (those that return the error 211) thingspeak, arduino, error 211 MATLAB Answers — New Questions
Can’t solve linker error in building S-Function Builder
I got this kind of model with S-Function Builder as shown in this image.
But When I build it, I got this error.
#’smex_builder.cpp’
was created successfully
###’smex_builder_wrapper.cpp’
was created successfully
###’smex_builder.tlc’
was created successfully
????? smex_builder.lib ??????? smex_builder.exp ???? smex_builder_wrapper.obj : error LNK2019: ?????????? OrtGetApiBase ??? "void __cdecl `dynamic initializer for ‘public: static struct OrtApi const * const Ort::Global::api_”(void)" (??__E?api_@?$Global@X@Ort@@2PEBUOrtApi@@EB@@YAXXZ) ???????? smex_builder.mexw64 : fatal error LNK1120: 1 ??????????
Also, I set parameter tab and library tab like this.
[Port and parameter] tab
[library] tab
I run " mex -setup C++" command and it shows Visual Studio 2022.
I use attached ONNX model as zip file.(out_modified_empty_model.onnx)
Structure of my onnx is like this.
Do you happen to know the solution?
I’m not sure about why this error… I’d be happy if you could give me any advice.
For your information,
I tried this C++ code in S-Function Builder Editor, but I can not figure out what is the cause and where I am missing.
#include "mex.h"
#include <math.h>
#include <onnxruntime_cxx_api.h>
#include <vector>
#include <memory>
extern std::unique_ptrOrt::Env g_env;
extern std::unique_ptrOrt::Session g_session;
extern std::vector<const char> g_input_node_names;
extern std::vector<const char*> g_output_node_names;
void smex_builder_Start_wrapper(void)
{
try {
g_env = std::make_uniqueOrt::Env(ORT_LOGGING_LEVEL_WARNING, "test");
Ort::SessionOptions session_options;
session_options.SetIntraOpNumThreads(1);
session_options.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_EXTENDED);
const wchar_t model_path = L"out_modified_empty_model.onnx";
g_session = std::make_uniqueOrt::Session(g_env, model_path, session_options);
Ort::AllocatorWithDefaultOptions allocator;
size_t num_input_nodes = g_session->GetInputCount();
g_input_node_names.resize(num_input_nodes);
for (size_t i = 0; i < num_input_nodes; i++) {
auto input_name = g_session->GetInputNameAllocated(i, allocator);
g_input_node_names[i] = input_name.get();
}
size_t num_output_nodes = g_session->GetOutputCount();
g_output_node_names.resize(num_output_nodes);
for (size_t i = 0; i < num_output_nodes; i++) {
auto output_name = g_session->GetOutputNameAllocated(i, allocator);
g_output_node_names[i] = output_name.get();
}
}
catch (const Ort::Exception& ex) {
mexErrMsgIdAndTxt("myOnnxSfunc:InitError", "初期化エラー: %s", ex.what());
}
}
void smex_builder_Outputs_wrapper(const real_T *u0,
const real_T *u1,
const real_T *u2,
const real_T *u3,
const real_T *u4,
const real_T *u5,
const real_T *u6,
real_T *y0,
real_T y1)
{
mexErrMsgIdAndTxt("mySfunc:TestError", "mexErrMsgIdAndTxt のテストエラー");
try {
std::vector<float> input_data(7);
input_data[0] = static_cast<float>(*u0);
input_data[1] = static_cast<float>(*u1);
input_data[2] = static_cast<float>(*u2);
input_data[3] = static_cast<float>(*u3);
input_data[4] = static_cast<float>(u4);
input_data[5] = static_cast<float>(u5);
input_data[6] = static_cast<float>(u6);
std::vector<int64_t> input_shape = { 1, 7 };
Ort::MemoryInfo memory_info = Ort::MemoryInfo::CreateCpu(OrtDeviceAllocator, OrtMemTypeCPU);
Ort::Value input_tensor = Ort::Value::CreateTensor<float>(
memory_info,
input_data.data(),
input_data.size(),
input_shape.data(),
input_shape.size()
);
auto output_tensors = g_session->Run(
Ort::RunOptions{ nullptr },
g_input_node_names.data(),
&input_tensor,
1,
g_output_node_names.data(),
g_output_node_names.size()
);
// Assuming your model outputs two tensors.
if (output_tensors.size() != 2) {
mexErrMsgIdAndTxt("myOnnxSfunc:OutputError",
"モデルは2つのテンソルを出力する必要があります。");
}
// Check the shape of the first output tensor.
float output_data0 = output_tensors[0].GetTensorMutableData<float>();
auto type_info0 = output_tensors[0].GetTensorTypeAndShapeInfo();
auto output_shape0 = type_info0.GetShape();
if (output_shape0.size() != 2 || output_shape0[0] != 1 || output_shape0[1] != 1) {
mexErrMsgIdAndTxt("myOnnxSfunc:OutputError",
"出力テンソル0の形状が不正です。期待される形状: (1, 1)");
}
// Check the shape of the second output tensor.
float output_data1 = output_tensors[1].GetTensorMutableData<float>();
auto type_info1 = output_tensors[1].GetTensorTypeAndShapeInfo();
auto output_shape1 = type_info1.GetShape();
if (output_shape1.size() != 2 || output_shape1[0] != 1 || output_shape1[1] != 1) {
mexErrMsgIdAndTxt("myOnnxSfunc:OutputError",
"出力テンソル1の形状が不正です。期待される形状: (1, 1)");
}
// Simulink出力ポートへの書き込み
y0[0] = static_cast<double>(output_data0[0]); // y0 に最初の出力
y1[0] = static_cast<double>(output_data1[0]); // y1 に2番目の出力
}
catch (const Ort::Exception& ex) {
mexErrMsgIdAndTxt("myOnnxSfunc:RuntimeError", "実行時エラー: %s", ex.what());
}
}
void smex_builder_Terminate_wrapper(void)
{
g_session.reset();
g_env.reset();
g_input_node_names.clear();
g_output_node_names.clear();
}I got this kind of model with S-Function Builder as shown in this image.
But When I build it, I got this error.
#’smex_builder.cpp’
was created successfully
###’smex_builder_wrapper.cpp’
was created successfully
###’smex_builder.tlc’
was created successfully
????? smex_builder.lib ??????? smex_builder.exp ???? smex_builder_wrapper.obj : error LNK2019: ?????????? OrtGetApiBase ??? "void __cdecl `dynamic initializer for ‘public: static struct OrtApi const * const Ort::Global::api_”(void)" (??__E?api_@?$Global@X@Ort@@2PEBUOrtApi@@EB@@YAXXZ) ???????? smex_builder.mexw64 : fatal error LNK1120: 1 ??????????
Also, I set parameter tab and library tab like this.
[Port and parameter] tab
[library] tab
I run " mex -setup C++" command and it shows Visual Studio 2022.
I use attached ONNX model as zip file.(out_modified_empty_model.onnx)
Structure of my onnx is like this.
Do you happen to know the solution?
I’m not sure about why this error… I’d be happy if you could give me any advice.
For your information,
I tried this C++ code in S-Function Builder Editor, but I can not figure out what is the cause and where I am missing.
#include "mex.h"
#include <math.h>
#include <onnxruntime_cxx_api.h>
#include <vector>
#include <memory>
extern std::unique_ptrOrt::Env g_env;
extern std::unique_ptrOrt::Session g_session;
extern std::vector<const char> g_input_node_names;
extern std::vector<const char*> g_output_node_names;
void smex_builder_Start_wrapper(void)
{
try {
g_env = std::make_uniqueOrt::Env(ORT_LOGGING_LEVEL_WARNING, "test");
Ort::SessionOptions session_options;
session_options.SetIntraOpNumThreads(1);
session_options.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_EXTENDED);
const wchar_t model_path = L"out_modified_empty_model.onnx";
g_session = std::make_uniqueOrt::Session(g_env, model_path, session_options);
Ort::AllocatorWithDefaultOptions allocator;
size_t num_input_nodes = g_session->GetInputCount();
g_input_node_names.resize(num_input_nodes);
for (size_t i = 0; i < num_input_nodes; i++) {
auto input_name = g_session->GetInputNameAllocated(i, allocator);
g_input_node_names[i] = input_name.get();
}
size_t num_output_nodes = g_session->GetOutputCount();
g_output_node_names.resize(num_output_nodes);
for (size_t i = 0; i < num_output_nodes; i++) {
auto output_name = g_session->GetOutputNameAllocated(i, allocator);
g_output_node_names[i] = output_name.get();
}
}
catch (const Ort::Exception& ex) {
mexErrMsgIdAndTxt("myOnnxSfunc:InitError", "初期化エラー: %s", ex.what());
}
}
void smex_builder_Outputs_wrapper(const real_T *u0,
const real_T *u1,
const real_T *u2,
const real_T *u3,
const real_T *u4,
const real_T *u5,
const real_T *u6,
real_T *y0,
real_T y1)
{
mexErrMsgIdAndTxt("mySfunc:TestError", "mexErrMsgIdAndTxt のテストエラー");
try {
std::vector<float> input_data(7);
input_data[0] = static_cast<float>(*u0);
input_data[1] = static_cast<float>(*u1);
input_data[2] = static_cast<float>(*u2);
input_data[3] = static_cast<float>(*u3);
input_data[4] = static_cast<float>(u4);
input_data[5] = static_cast<float>(u5);
input_data[6] = static_cast<float>(u6);
std::vector<int64_t> input_shape = { 1, 7 };
Ort::MemoryInfo memory_info = Ort::MemoryInfo::CreateCpu(OrtDeviceAllocator, OrtMemTypeCPU);
Ort::Value input_tensor = Ort::Value::CreateTensor<float>(
memory_info,
input_data.data(),
input_data.size(),
input_shape.data(),
input_shape.size()
);
auto output_tensors = g_session->Run(
Ort::RunOptions{ nullptr },
g_input_node_names.data(),
&input_tensor,
1,
g_output_node_names.data(),
g_output_node_names.size()
);
// Assuming your model outputs two tensors.
if (output_tensors.size() != 2) {
mexErrMsgIdAndTxt("myOnnxSfunc:OutputError",
"モデルは2つのテンソルを出力する必要があります。");
}
// Check the shape of the first output tensor.
float output_data0 = output_tensors[0].GetTensorMutableData<float>();
auto type_info0 = output_tensors[0].GetTensorTypeAndShapeInfo();
auto output_shape0 = type_info0.GetShape();
if (output_shape0.size() != 2 || output_shape0[0] != 1 || output_shape0[1] != 1) {
mexErrMsgIdAndTxt("myOnnxSfunc:OutputError",
"出力テンソル0の形状が不正です。期待される形状: (1, 1)");
}
// Check the shape of the second output tensor.
float output_data1 = output_tensors[1].GetTensorMutableData<float>();
auto type_info1 = output_tensors[1].GetTensorTypeAndShapeInfo();
auto output_shape1 = type_info1.GetShape();
if (output_shape1.size() != 2 || output_shape1[0] != 1 || output_shape1[1] != 1) {
mexErrMsgIdAndTxt("myOnnxSfunc:OutputError",
"出力テンソル1の形状が不正です。期待される形状: (1, 1)");
}
// Simulink出力ポートへの書き込み
y0[0] = static_cast<double>(output_data0[0]); // y0 に最初の出力
y1[0] = static_cast<double>(output_data1[0]); // y1 に2番目の出力
}
catch (const Ort::Exception& ex) {
mexErrMsgIdAndTxt("myOnnxSfunc:RuntimeError", "実行時エラー: %s", ex.what());
}
}
void smex_builder_Terminate_wrapper(void)
{
g_session.reset();
g_env.reset();
g_input_node_names.clear();
g_output_node_names.clear();
} I got this kind of model with S-Function Builder as shown in this image.
But When I build it, I got this error.
#’smex_builder.cpp’
was created successfully
###’smex_builder_wrapper.cpp’
was created successfully
###’smex_builder.tlc’
was created successfully
????? smex_builder.lib ??????? smex_builder.exp ???? smex_builder_wrapper.obj : error LNK2019: ?????????? OrtGetApiBase ??? "void __cdecl `dynamic initializer for ‘public: static struct OrtApi const * const Ort::Global::api_”(void)" (??__E?api_@?$Global@X@Ort@@2PEBUOrtApi@@EB@@YAXXZ) ???????? smex_builder.mexw64 : fatal error LNK1120: 1 ??????????
Also, I set parameter tab and library tab like this.
[Port and parameter] tab
[library] tab
I run " mex -setup C++" command and it shows Visual Studio 2022.
I use attached ONNX model as zip file.(out_modified_empty_model.onnx)
Structure of my onnx is like this.
Do you happen to know the solution?
I’m not sure about why this error… I’d be happy if you could give me any advice.
For your information,
I tried this C++ code in S-Function Builder Editor, but I can not figure out what is the cause and where I am missing.
#include "mex.h"
#include <math.h>
#include <onnxruntime_cxx_api.h>
#include <vector>
#include <memory>
extern std::unique_ptrOrt::Env g_env;
extern std::unique_ptrOrt::Session g_session;
extern std::vector<const char> g_input_node_names;
extern std::vector<const char*> g_output_node_names;
void smex_builder_Start_wrapper(void)
{
try {
g_env = std::make_uniqueOrt::Env(ORT_LOGGING_LEVEL_WARNING, "test");
Ort::SessionOptions session_options;
session_options.SetIntraOpNumThreads(1);
session_options.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_EXTENDED);
const wchar_t model_path = L"out_modified_empty_model.onnx";
g_session = std::make_uniqueOrt::Session(g_env, model_path, session_options);
Ort::AllocatorWithDefaultOptions allocator;
size_t num_input_nodes = g_session->GetInputCount();
g_input_node_names.resize(num_input_nodes);
for (size_t i = 0; i < num_input_nodes; i++) {
auto input_name = g_session->GetInputNameAllocated(i, allocator);
g_input_node_names[i] = input_name.get();
}
size_t num_output_nodes = g_session->GetOutputCount();
g_output_node_names.resize(num_output_nodes);
for (size_t i = 0; i < num_output_nodes; i++) {
auto output_name = g_session->GetOutputNameAllocated(i, allocator);
g_output_node_names[i] = output_name.get();
}
}
catch (const Ort::Exception& ex) {
mexErrMsgIdAndTxt("myOnnxSfunc:InitError", "初期化エラー: %s", ex.what());
}
}
void smex_builder_Outputs_wrapper(const real_T *u0,
const real_T *u1,
const real_T *u2,
const real_T *u3,
const real_T *u4,
const real_T *u5,
const real_T *u6,
real_T *y0,
real_T y1)
{
mexErrMsgIdAndTxt("mySfunc:TestError", "mexErrMsgIdAndTxt のテストエラー");
try {
std::vector<float> input_data(7);
input_data[0] = static_cast<float>(*u0);
input_data[1] = static_cast<float>(*u1);
input_data[2] = static_cast<float>(*u2);
input_data[3] = static_cast<float>(*u3);
input_data[4] = static_cast<float>(u4);
input_data[5] = static_cast<float>(u5);
input_data[6] = static_cast<float>(u6);
std::vector<int64_t> input_shape = { 1, 7 };
Ort::MemoryInfo memory_info = Ort::MemoryInfo::CreateCpu(OrtDeviceAllocator, OrtMemTypeCPU);
Ort::Value input_tensor = Ort::Value::CreateTensor<float>(
memory_info,
input_data.data(),
input_data.size(),
input_shape.data(),
input_shape.size()
);
auto output_tensors = g_session->Run(
Ort::RunOptions{ nullptr },
g_input_node_names.data(),
&input_tensor,
1,
g_output_node_names.data(),
g_output_node_names.size()
);
// Assuming your model outputs two tensors.
if (output_tensors.size() != 2) {
mexErrMsgIdAndTxt("myOnnxSfunc:OutputError",
"モデルは2つのテンソルを出力する必要があります。");
}
// Check the shape of the first output tensor.
float output_data0 = output_tensors[0].GetTensorMutableData<float>();
auto type_info0 = output_tensors[0].GetTensorTypeAndShapeInfo();
auto output_shape0 = type_info0.GetShape();
if (output_shape0.size() != 2 || output_shape0[0] != 1 || output_shape0[1] != 1) {
mexErrMsgIdAndTxt("myOnnxSfunc:OutputError",
"出力テンソル0の形状が不正です。期待される形状: (1, 1)");
}
// Check the shape of the second output tensor.
float output_data1 = output_tensors[1].GetTensorMutableData<float>();
auto type_info1 = output_tensors[1].GetTensorTypeAndShapeInfo();
auto output_shape1 = type_info1.GetShape();
if (output_shape1.size() != 2 || output_shape1[0] != 1 || output_shape1[1] != 1) {
mexErrMsgIdAndTxt("myOnnxSfunc:OutputError",
"出力テンソル1の形状が不正です。期待される形状: (1, 1)");
}
// Simulink出力ポートへの書き込み
y0[0] = static_cast<double>(output_data0[0]); // y0 に最初の出力
y1[0] = static_cast<double>(output_data1[0]); // y1 に2番目の出力
}
catch (const Ort::Exception& ex) {
mexErrMsgIdAndTxt("myOnnxSfunc:RuntimeError", "実行時エラー: %s", ex.what());
}
}
void smex_builder_Terminate_wrapper(void)
{
g_session.reset();
g_env.reset();
g_input_node_names.clear();
g_output_node_names.clear();
} s-function, c++ MATLAB Answers — New Questions
How to Create a Standalone .exe File from Simulink Code?
Hello Community,
I’m currently working on creating a standalone executable (.exe) from my Simulink project, and I need some guidance.
Here’s my current setup:
I have a .m file that loads variables into the workspace and runs the simulation. It also processes and visualizes the results afterward.
I used Simulink Coder to generate C code from the Simulink model. I chose the option to generate code only (without "Execute Makefile"), so now I have a collection of .c and .h files.
My questions:
How can I use these generated files to build a standalone .exe file?
Do I need additional files from the MATLAB/Simulink installation (e.g., libraries, .c files or other runtime components)?
Is it possible to use Visual Studio or another compiler to compile the .c files into an executable? If yes, are there specific steps or configurations I need to follow?
I’m relatively new to this process, so I appreciate any instructions or resources to help me bridge the gap from generated C code to a functional executable.
Thank you in advance for your help!
Best regards,
AaronHello Community,
I’m currently working on creating a standalone executable (.exe) from my Simulink project, and I need some guidance.
Here’s my current setup:
I have a .m file that loads variables into the workspace and runs the simulation. It also processes and visualizes the results afterward.
I used Simulink Coder to generate C code from the Simulink model. I chose the option to generate code only (without "Execute Makefile"), so now I have a collection of .c and .h files.
My questions:
How can I use these generated files to build a standalone .exe file?
Do I need additional files from the MATLAB/Simulink installation (e.g., libraries, .c files or other runtime components)?
Is it possible to use Visual Studio or another compiler to compile the .c files into an executable? If yes, are there specific steps or configurations I need to follow?
I’m relatively new to this process, so I appreciate any instructions or resources to help me bridge the gap from generated C code to a functional executable.
Thank you in advance for your help!
Best regards,
Aaron Hello Community,
I’m currently working on creating a standalone executable (.exe) from my Simulink project, and I need some guidance.
Here’s my current setup:
I have a .m file that loads variables into the workspace and runs the simulation. It also processes and visualizes the results afterward.
I used Simulink Coder to generate C code from the Simulink model. I chose the option to generate code only (without "Execute Makefile"), so now I have a collection of .c and .h files.
My questions:
How can I use these generated files to build a standalone .exe file?
Do I need additional files from the MATLAB/Simulink installation (e.g., libraries, .c files or other runtime components)?
Is it possible to use Visual Studio or another compiler to compile the .c files into an executable? If yes, are there specific steps or configurations I need to follow?
I’m relatively new to this process, so I appreciate any instructions or resources to help me bridge the gap from generated C code to a functional executable.
Thank you in advance for your help!
Best regards,
Aaron exe, c++, simulink MATLAB Answers — New Questions
Trying to plot two vectors of unequal lengths on the same X and Y axes
Hello, I am trying to plot two vectors of unequal lengths on the same set of axes. One potential solution I have thought of is to bin the longer vector, such that the number of bins equals the length of the smaller vector. Then, I could take the average within each bin. However, I dont know how I would go about doing this, or if there is some other way.
I would appreciate any help in trying to figure this out! Thank you!Hello, I am trying to plot two vectors of unequal lengths on the same set of axes. One potential solution I have thought of is to bin the longer vector, such that the number of bins equals the length of the smaller vector. Then, I could take the average within each bin. However, I dont know how I would go about doing this, or if there is some other way.
I would appreciate any help in trying to figure this out! Thank you! Hello, I am trying to plot two vectors of unequal lengths on the same set of axes. One potential solution I have thought of is to bin the longer vector, such that the number of bins equals the length of the smaller vector. Then, I could take the average within each bin. However, I dont know how I would go about doing this, or if there is some other way.
I would appreciate any help in trying to figure this out! Thank you! vectors, binning, average, plot MATLAB Answers — New Questions