Tag Archives: matlab
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
Which statistic is minimized in curve fitting app
Dear colleagues,
The statistics which evaluate the goodness of in the Curve Fitting app are shown in the picture below.
At this link is given a description of each of these.
https://nl.mathworks.com/help/curvefit/evaluating-goodness-of-fit.html
My question is what parameter/statistic is minimized to make a fit? In another discussion I have read something about 2-norm. So is some of shown above a 2-norm?Dear colleagues,
The statistics which evaluate the goodness of in the Curve Fitting app are shown in the picture below.
At this link is given a description of each of these.
https://nl.mathworks.com/help/curvefit/evaluating-goodness-of-fit.html
My question is what parameter/statistic is minimized to make a fit? In another discussion I have read something about 2-norm. So is some of shown above a 2-norm? Dear colleagues,
The statistics which evaluate the goodness of in the Curve Fitting app are shown in the picture below.
At this link is given a description of each of these.
https://nl.mathworks.com/help/curvefit/evaluating-goodness-of-fit.html
My question is what parameter/statistic is minimized to make a fit? In another discussion I have read something about 2-norm. So is some of shown above a 2-norm? curve fitting MATLAB Answers — New Questions
CRLB in Mean Square Error
in my code i am having FIM Function[ function [J_11, J_12, J_22] = FIM(para, Rx, beta, scale)]. i want to use this function in my dnn for MSE to calculate traces of CRLB. how i can doin my code i am having FIM Function[ function [J_11, J_12, J_22] = FIM(para, Rx, beta, scale)]. i want to use this function in my dnn for MSE to calculate traces of CRLB. how i can do in my code i am having FIM Function[ function [J_11, J_12, J_22] = FIM(para, Rx, beta, scale)]. i want to use this function in my dnn for MSE to calculate traces of CRLB. how i can do crlb, mse MATLAB Answers — New Questions
What happens if I set both RelTol and AbsTol for ODE45 and/or both TolX and Tolfun for FSOLVE?
I’m solving an eigenvalue problem via a combination of ODE45 and FSOLVE, and I’m not sure what happens if I set both RelTol and AbsTol for the former and both TolX and Tolfun for the latter. Do these functions refine steps, etc. until both requirements are satisfied or only one of them?I’m solving an eigenvalue problem via a combination of ODE45 and FSOLVE, and I’m not sure what happens if I set both RelTol and AbsTol for the former and both TolX and Tolfun for the latter. Do these functions refine steps, etc. until both requirements are satisfied or only one of them? I’m solving an eigenvalue problem via a combination of ODE45 and FSOLVE, and I’m not sure what happens if I set both RelTol and AbsTol for the former and both TolX and Tolfun for the latter. Do these functions refine steps, etc. until both requirements are satisfied or only one of them? ode45, fsolve, tolerance MATLAB Answers — New Questions
PNG file saving in power point presentation
clear
clc
%removed the clear all, close all, clc, as they are irrelevant here and can only cause problems
project_dir = pwd(); %new
% List all current folder contents ending with .png. Resulting names will
% appear in the order returned by the operating system.
files = dir( fullfile(project_dir, ‘*.png’)); %changed
% Create Common Object Model (COM) server so MATLAB can export data to
% PowerPoint
g = actxserver(‘powerpoint.application’);
% Open PowerPoint and make it visible
g.Visible = 1;
Presentation = g.Presentation;
% Prompt the user for the PowerPoint file to amend
[fn, pn] = uigetfile(‘*.pptx’, ‘Select PowerPoint File To Amend’);
filename = fullfile(pn, fn); %changed
Presentation = invoke(Presentation, ‘open’, filename);
% Get current number of slides
slide_count = get(Presentation.Slides, ‘Count’);
% Export all PNGs in the current directory to the PowerPoint file specified
% above. The following slides will be added to the END of the PowerPoint
% file. All slides will have a common title.
for i=1:length(files)
slide_count = int32(double(slide_count)+1);
slide = invoke(Presentation.Slides, ‘Add’, slide_count{i}, 11);
set(slide.Shapes.Title.Textframe.Textrange, ‘Text’, ‘SomeTitle’);
slidefile = fullfile(project_dir, files(i).name); %new
Image{i} = slide.Shapes.AddPicture(slidefile, ‘msoFalse’, ‘msoTrue’, 0, 80, 720, 440); %changed
end
% Save the amended PowerPoint presentation to the current directory
outfile = fullfile(project_dir, ‘DRAFT.pptx’); %new
Presentation.SaveAs(outfile); %changed
% Close PowerPoint as a COM automation server
g.Quit;
g.delete;
If i have 4 PNG images in a folder , how can i save (present) those in a single slide in power point using MATLAB code? I am using the code below but showing some error.clear
clc
%removed the clear all, close all, clc, as they are irrelevant here and can only cause problems
project_dir = pwd(); %new
% List all current folder contents ending with .png. Resulting names will
% appear in the order returned by the operating system.
files = dir( fullfile(project_dir, ‘*.png’)); %changed
% Create Common Object Model (COM) server so MATLAB can export data to
% PowerPoint
g = actxserver(‘powerpoint.application’);
% Open PowerPoint and make it visible
g.Visible = 1;
Presentation = g.Presentation;
% Prompt the user for the PowerPoint file to amend
[fn, pn] = uigetfile(‘*.pptx’, ‘Select PowerPoint File To Amend’);
filename = fullfile(pn, fn); %changed
Presentation = invoke(Presentation, ‘open’, filename);
% Get current number of slides
slide_count = get(Presentation.Slides, ‘Count’);
% Export all PNGs in the current directory to the PowerPoint file specified
% above. The following slides will be added to the END of the PowerPoint
% file. All slides will have a common title.
for i=1:length(files)
slide_count = int32(double(slide_count)+1);
slide = invoke(Presentation.Slides, ‘Add’, slide_count{i}, 11);
set(slide.Shapes.Title.Textframe.Textrange, ‘Text’, ‘SomeTitle’);
slidefile = fullfile(project_dir, files(i).name); %new
Image{i} = slide.Shapes.AddPicture(slidefile, ‘msoFalse’, ‘msoTrue’, 0, 80, 720, 440); %changed
end
% Save the amended PowerPoint presentation to the current directory
outfile = fullfile(project_dir, ‘DRAFT.pptx’); %new
Presentation.SaveAs(outfile); %changed
% Close PowerPoint as a COM automation server
g.Quit;
g.delete;
If i have 4 PNG images in a folder , how can i save (present) those in a single slide in power point using MATLAB code? I am using the code below but showing some error. clear
clc
%removed the clear all, close all, clc, as they are irrelevant here and can only cause problems
project_dir = pwd(); %new
% List all current folder contents ending with .png. Resulting names will
% appear in the order returned by the operating system.
files = dir( fullfile(project_dir, ‘*.png’)); %changed
% Create Common Object Model (COM) server so MATLAB can export data to
% PowerPoint
g = actxserver(‘powerpoint.application’);
% Open PowerPoint and make it visible
g.Visible = 1;
Presentation = g.Presentation;
% Prompt the user for the PowerPoint file to amend
[fn, pn] = uigetfile(‘*.pptx’, ‘Select PowerPoint File To Amend’);
filename = fullfile(pn, fn); %changed
Presentation = invoke(Presentation, ‘open’, filename);
% Get current number of slides
slide_count = get(Presentation.Slides, ‘Count’);
% Export all PNGs in the current directory to the PowerPoint file specified
% above. The following slides will be added to the END of the PowerPoint
% file. All slides will have a common title.
for i=1:length(files)
slide_count = int32(double(slide_count)+1);
slide = invoke(Presentation.Slides, ‘Add’, slide_count{i}, 11);
set(slide.Shapes.Title.Textframe.Textrange, ‘Text’, ‘SomeTitle’);
slidefile = fullfile(project_dir, files(i).name); %new
Image{i} = slide.Shapes.AddPicture(slidefile, ‘msoFalse’, ‘msoTrue’, 0, 80, 720, 440); %changed
end
% Save the amended PowerPoint presentation to the current directory
outfile = fullfile(project_dir, ‘DRAFT.pptx’); %new
Presentation.SaveAs(outfile); %changed
% Close PowerPoint as a COM automation server
g.Quit;
g.delete;
If i have 4 PNG images in a folder , how can i save (present) those in a single slide in power point using MATLAB code? I am using the code below but showing some error. image MATLAB Answers — New Questions
I need to draw a shape in matlab help me
Hi,I simulate something in matlab .For those wondering, this is the cross section of the rotor in the axial compressor.. I want to draw this picture in matlab same dimensions,same angles,and same shape.Additionally, I would like to have red dots at the corners of the angled areas where they intersect with the horizontal axes. I am open to your suggestions regarding this.Of course, dashed lines also need to be drawn. The dashed lines can be in blue. My drawing needs to start from the origin point.It needs to be added to the code I will post below and changed when I change the values related to the shape in the code.
% datas
rpm = 30000; % rev/min
Pti_Pte = 1.5; % compression ratio
efficiency = 0.9; % isentropic efficiency
mass_flow_rate = 1.6; % kg/s
r1s = 0.15; % m (stator distance from rotor axis)
aspect_ratio = 0.7; % geometrical ratio
P_amb = 101325; % Pa
T0 = 288.15; % K (environmental temperature)
gamma = 1.4; % specific heat ratio of air
cp = 1005; % J/(kg·K)
load_coefficient = 0.4;
% Calculating chord length and r2h from aspect ratio
chord = r1s / aspect_ratio; % chord = span / aspect_ratio
r2h = r1s – chord; % Shroud radius
% Step 1: Isenthalpic Relations and Tt2s Calculation
Tt1 = T0; % St2-St1 = 0
Tt2s = Tt1 * (Pti_Pte ^ ((gamma – 1) / gamma));
% Step 2: Tt2 calculations
Tt2 = Tt1 + (Tt2s – Tt1) / efficiency;
% Step 3: Enthalpy change (Delta H)
delta_h = cp * (Tt2 – Tt1); % J/kg
% Step 4: Umean calculation
U_mean = sqrt(delta_h / load_coefficient); % m/s
% Step 5: Axial velocity ve Mach Number
rho = P_amb / (287 * T0); % Density, ideal gas equation
V_axial = U_mean *0.5; % Axial hız
Mach = V_axial / sqrt(gamma * 287 * T0); % Mach sayısı
% Step 6: Calculation of Angles
V_theta2 = delta_h / U_mean; %
beta1 = atan(U_mean / V_axial)* (180 / pi); % Beta1 angle (degree)
beta2 = atan((U_mean – V_theta2) / V_axial) * (180 / pi); % Beta2 angle (degree)
% % Visualization of Results
fprintf(‘Tt2s: %.2f Kn’, Tt2s);
fprintf(‘Tt2: %.2f Kn’, Tt2);
fprintf(‘Delta H: %.2f J/kgn’, delta_h);
fprintf(‘Umean: %.2f m/sn’, U_mean);
fprintf(‘Mach Number: %.2fn’, Mach);
fprintf(‘V_axial: %.2f m/sn’, V_axial);
fprintf(‘V_theta2: %.2f m/sn’, V_theta2);
fprintf(‘Beta1: %.2f derecen’, beta1);
fprintf(‘Beta2: %.2f derecen’, beta2);Hi,I simulate something in matlab .For those wondering, this is the cross section of the rotor in the axial compressor.. I want to draw this picture in matlab same dimensions,same angles,and same shape.Additionally, I would like to have red dots at the corners of the angled areas where they intersect with the horizontal axes. I am open to your suggestions regarding this.Of course, dashed lines also need to be drawn. The dashed lines can be in blue. My drawing needs to start from the origin point.It needs to be added to the code I will post below and changed when I change the values related to the shape in the code.
% datas
rpm = 30000; % rev/min
Pti_Pte = 1.5; % compression ratio
efficiency = 0.9; % isentropic efficiency
mass_flow_rate = 1.6; % kg/s
r1s = 0.15; % m (stator distance from rotor axis)
aspect_ratio = 0.7; % geometrical ratio
P_amb = 101325; % Pa
T0 = 288.15; % K (environmental temperature)
gamma = 1.4; % specific heat ratio of air
cp = 1005; % J/(kg·K)
load_coefficient = 0.4;
% Calculating chord length and r2h from aspect ratio
chord = r1s / aspect_ratio; % chord = span / aspect_ratio
r2h = r1s – chord; % Shroud radius
% Step 1: Isenthalpic Relations and Tt2s Calculation
Tt1 = T0; % St2-St1 = 0
Tt2s = Tt1 * (Pti_Pte ^ ((gamma – 1) / gamma));
% Step 2: Tt2 calculations
Tt2 = Tt1 + (Tt2s – Tt1) / efficiency;
% Step 3: Enthalpy change (Delta H)
delta_h = cp * (Tt2 – Tt1); % J/kg
% Step 4: Umean calculation
U_mean = sqrt(delta_h / load_coefficient); % m/s
% Step 5: Axial velocity ve Mach Number
rho = P_amb / (287 * T0); % Density, ideal gas equation
V_axial = U_mean *0.5; % Axial hız
Mach = V_axial / sqrt(gamma * 287 * T0); % Mach sayısı
% Step 6: Calculation of Angles
V_theta2 = delta_h / U_mean; %
beta1 = atan(U_mean / V_axial)* (180 / pi); % Beta1 angle (degree)
beta2 = atan((U_mean – V_theta2) / V_axial) * (180 / pi); % Beta2 angle (degree)
% % Visualization of Results
fprintf(‘Tt2s: %.2f Kn’, Tt2s);
fprintf(‘Tt2: %.2f Kn’, Tt2);
fprintf(‘Delta H: %.2f J/kgn’, delta_h);
fprintf(‘Umean: %.2f m/sn’, U_mean);
fprintf(‘Mach Number: %.2fn’, Mach);
fprintf(‘V_axial: %.2f m/sn’, V_axial);
fprintf(‘V_theta2: %.2f m/sn’, V_theta2);
fprintf(‘Beta1: %.2f derecen’, beta1);
fprintf(‘Beta2: %.2f derecen’, beta2); Hi,I simulate something in matlab .For those wondering, this is the cross section of the rotor in the axial compressor.. I want to draw this picture in matlab same dimensions,same angles,and same shape.Additionally, I would like to have red dots at the corners of the angled areas where they intersect with the horizontal axes. I am open to your suggestions regarding this.Of course, dashed lines also need to be drawn. The dashed lines can be in blue. My drawing needs to start from the origin point.It needs to be added to the code I will post below and changed when I change the values related to the shape in the code.
% datas
rpm = 30000; % rev/min
Pti_Pte = 1.5; % compression ratio
efficiency = 0.9; % isentropic efficiency
mass_flow_rate = 1.6; % kg/s
r1s = 0.15; % m (stator distance from rotor axis)
aspect_ratio = 0.7; % geometrical ratio
P_amb = 101325; % Pa
T0 = 288.15; % K (environmental temperature)
gamma = 1.4; % specific heat ratio of air
cp = 1005; % J/(kg·K)
load_coefficient = 0.4;
% Calculating chord length and r2h from aspect ratio
chord = r1s / aspect_ratio; % chord = span / aspect_ratio
r2h = r1s – chord; % Shroud radius
% Step 1: Isenthalpic Relations and Tt2s Calculation
Tt1 = T0; % St2-St1 = 0
Tt2s = Tt1 * (Pti_Pte ^ ((gamma – 1) / gamma));
% Step 2: Tt2 calculations
Tt2 = Tt1 + (Tt2s – Tt1) / efficiency;
% Step 3: Enthalpy change (Delta H)
delta_h = cp * (Tt2 – Tt1); % J/kg
% Step 4: Umean calculation
U_mean = sqrt(delta_h / load_coefficient); % m/s
% Step 5: Axial velocity ve Mach Number
rho = P_amb / (287 * T0); % Density, ideal gas equation
V_axial = U_mean *0.5; % Axial hız
Mach = V_axial / sqrt(gamma * 287 * T0); % Mach sayısı
% Step 6: Calculation of Angles
V_theta2 = delta_h / U_mean; %
beta1 = atan(U_mean / V_axial)* (180 / pi); % Beta1 angle (degree)
beta2 = atan((U_mean – V_theta2) / V_axial) * (180 / pi); % Beta2 angle (degree)
% % Visualization of Results
fprintf(‘Tt2s: %.2f Kn’, Tt2s);
fprintf(‘Tt2: %.2f Kn’, Tt2);
fprintf(‘Delta H: %.2f J/kgn’, delta_h);
fprintf(‘Umean: %.2f m/sn’, U_mean);
fprintf(‘Mach Number: %.2fn’, Mach);
fprintf(‘V_axial: %.2f m/sn’, V_axial);
fprintf(‘V_theta2: %.2f m/sn’, V_theta2);
fprintf(‘Beta1: %.2f derecen’, beta1);
fprintf(‘Beta2: %.2f derecen’, beta2); figure, circle, gas turbine, compressor, rotor, color, variable MATLAB Answers — New Questions
Microsoft Word Check Box
HI,
Could someone offer a solution to use Matlab to read a word template and Tick Check Boxes such the ones illustrated below. ThanksHI,
Could someone offer a solution to use Matlab to read a word template and Tick Check Boxes such the ones illustrated below. Thanks HI,
Could someone offer a solution to use Matlab to read a word template and Tick Check Boxes such the ones illustrated below. Thanks word, check box MATLAB Answers — New Questions
command history with updates
How do I import my command history from a previous release, once I have installed a new one ?How do I import my command history from a previous release, once I have installed a new one ? How do I import my command history from a previous release, once I have installed a new one ? command history MATLAB Answers — New Questions
How to solve the error: Exception in thread “AWT-EventQueue-0” java.lang.IllegalArgumentException: Comparison method violates its general contract!
Hello,
I started receiving an error in matlab, which prevents me to see the command window but does not prevent the code from executing. I attached all the error message below. I do not know why this is happening but I guess it started after I used "save" commands in the editor. I basically load data into the editor and then preprocess the data so that I can use them later, and I save the new data for future computations. Since when I started saving data, this problem has been initiated. Now, I can’t stop matlab to produce this error every time I run any code. Can you please help me with this? I really appreciate that, thank you.
Original error:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeHi(Unknown Source)
at java.util.TimSort.mergeAt(Unknown Source)
at java.util.TimSort.mergeCollapse(Unknown Source)
at java.util.TimSort.sort(Unknown Source)
at java.util.Arrays.sort(Unknown Source)
at java.util.ArrayList.sort(Unknown Source)
at java.util.Collections.sort(Unknown Source)
at com.mathworks.widgets.grouptable.GroupingTableUtils.sortNonRecursively(GroupingTableUtils.java:296)
at com.mathworks.widgets.grouptable.RowListTransactionTarget.finishTransaction(RowListTransactionTarget.java:115)
at com.mathworks.widgets.grouptable.GroupingTableTransaction$1.run(GroupingTableTransaction.java:112)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
>>
Sincerely,
Irem VelibeyogluHello,
I started receiving an error in matlab, which prevents me to see the command window but does not prevent the code from executing. I attached all the error message below. I do not know why this is happening but I guess it started after I used "save" commands in the editor. I basically load data into the editor and then preprocess the data so that I can use them later, and I save the new data for future computations. Since when I started saving data, this problem has been initiated. Now, I can’t stop matlab to produce this error every time I run any code. Can you please help me with this? I really appreciate that, thank you.
Original error:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeHi(Unknown Source)
at java.util.TimSort.mergeAt(Unknown Source)
at java.util.TimSort.mergeCollapse(Unknown Source)
at java.util.TimSort.sort(Unknown Source)
at java.util.Arrays.sort(Unknown Source)
at java.util.ArrayList.sort(Unknown Source)
at java.util.Collections.sort(Unknown Source)
at com.mathworks.widgets.grouptable.GroupingTableUtils.sortNonRecursively(GroupingTableUtils.java:296)
at com.mathworks.widgets.grouptable.RowListTransactionTarget.finishTransaction(RowListTransactionTarget.java:115)
at com.mathworks.widgets.grouptable.GroupingTableTransaction$1.run(GroupingTableTransaction.java:112)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
>>
Sincerely,
Irem Velibeyoglu Hello,
I started receiving an error in matlab, which prevents me to see the command window but does not prevent the code from executing. I attached all the error message below. I do not know why this is happening but I guess it started after I used "save" commands in the editor. I basically load data into the editor and then preprocess the data so that I can use them later, and I save the new data for future computations. Since when I started saving data, this problem has been initiated. Now, I can’t stop matlab to produce this error every time I run any code. Can you please help me with this? I really appreciate that, thank you.
Original error:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeHi(Unknown Source)
at java.util.TimSort.mergeAt(Unknown Source)
at java.util.TimSort.mergeCollapse(Unknown Source)
at java.util.TimSort.sort(Unknown Source)
at java.util.Arrays.sort(Unknown Source)
at java.util.ArrayList.sort(Unknown Source)
at java.util.Collections.sort(Unknown Source)
at com.mathworks.widgets.grouptable.GroupingTableUtils.sortNonRecursively(GroupingTableUtils.java:296)
at com.mathworks.widgets.grouptable.RowListTransactionTarget.finishTransaction(RowListTransactionTarget.java:115)
at com.mathworks.widgets.grouptable.GroupingTableTransaction$1.run(GroupingTableTransaction.java:112)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
>>
Sincerely,
Irem Velibeyoglu java error MATLAB Answers — New Questions
Solving Unit Commitment using PSO
Dear Brother,
Anybody can help me to solve my unit commitment problem using PSO in Matlab? Here is below several probem I can’t solve it and I attach the example code as your consideration.
How determines ramp rates limit to solve UC using PSO
I get trouble to execute my code in 168 hour (a week), it’s always show me error. But when I run in maximum time 96 hours or less than it (Monday, Wednesday, Friday and Load sample) it’s okay.
Thank you
Best Regards,
RZLDear Brother,
Anybody can help me to solve my unit commitment problem using PSO in Matlab? Here is below several probem I can’t solve it and I attach the example code as your consideration.
How determines ramp rates limit to solve UC using PSO
I get trouble to execute my code in 168 hour (a week), it’s always show me error. But when I run in maximum time 96 hours or less than it (Monday, Wednesday, Friday and Load sample) it’s okay.
Thank you
Best Regards,
RZL Dear Brother,
Anybody can help me to solve my unit commitment problem using PSO in Matlab? Here is below several probem I can’t solve it and I attach the example code as your consideration.
How determines ramp rates limit to solve UC using PSO
I get trouble to execute my code in 168 hour (a week), it’s always show me error. But when I run in maximum time 96 hours or less than it (Monday, Wednesday, Friday and Load sample) it’s okay.
Thank you
Best Regards,
RZL matlab, uc, unit commitment, pso, optimization MATLAB Answers — New Questions
Radiation pattern code needed.
Can someone please help me to plot a radiation pattern of a H-plane horn antenna in matlab. I have tried so many times but it doesn’t work. Please share the code if somebody has it. thanks a bunch.Can someone please help me to plot a radiation pattern of a H-plane horn antenna in matlab. I have tried so many times but it doesn’t work. Please share the code if somebody has it. thanks a bunch. Can someone please help me to plot a radiation pattern of a H-plane horn antenna in matlab. I have tried so many times but it doesn’t work. Please share the code if somebody has it. thanks a bunch. horn antenna, radiation pattern. MATLAB Answers — New Questions
Hotkeys not working in matlab
Hi everyone! For some unknown reason, hotkeys do not work in the editor and command window. When I select the hotkey editor in the settings, for example Ctrl+W… I’m trying to set Ctrl+W, i press Ctrl+W but Matlab displays it as Ctrl+[]. So it’s like it can’t understand the symbol. Plz help. It’s impossible to work without Ctrl+Z, Ctrl+C, etc.
OS: Pop!_OS 22.04 LTS x86_64Hi everyone! For some unknown reason, hotkeys do not work in the editor and command window. When I select the hotkey editor in the settings, for example Ctrl+W… I’m trying to set Ctrl+W, i press Ctrl+W but Matlab displays it as Ctrl+[]. So it’s like it can’t understand the symbol. Plz help. It’s impossible to work without Ctrl+Z, Ctrl+C, etc.
OS: Pop!_OS 22.04 LTS x86_64 Hi everyone! For some unknown reason, hotkeys do not work in the editor and command window. When I select the hotkey editor in the settings, for example Ctrl+W… I’m trying to set Ctrl+W, i press Ctrl+W but Matlab displays it as Ctrl+[]. So it’s like it can’t understand the symbol. Plz help. It’s impossible to work without Ctrl+Z, Ctrl+C, etc.
OS: Pop!_OS 22.04 LTS x86_64 linux, keyboard, hotkeys MATLAB Answers — New Questions
how use categorical in uitable
VNAMES={‘On’,’Trading’,’L_S’,’Stat’,’PROVA’,’Cap’,’Perc’,’Draw_Sys’};
cat=categorical({‘Fil’;’Stat’});
VTYPES=[{‘logical’},{‘string’},{‘string’},{‘double’},{‘double’},{‘cat’},{‘double’},{‘logical’}];
T=table(‘Size’,[nrows,numel(VNAMES)],’VariableTypes’,VTYPES,’VariableNames’,VNAMES);
Error using table (line 310)
Specify variable types as a string array or a cell array of character
vectors, such as ["string", "datetime", "double"].
i try to use in vtypes : {‘cat’}..{cat}…{"cat"} but it give me an errorVNAMES={‘On’,’Trading’,’L_S’,’Stat’,’PROVA’,’Cap’,’Perc’,’Draw_Sys’};
cat=categorical({‘Fil’;’Stat’});
VTYPES=[{‘logical’},{‘string’},{‘string’},{‘double’},{‘double’},{‘cat’},{‘double’},{‘logical’}];
T=table(‘Size’,[nrows,numel(VNAMES)],’VariableTypes’,VTYPES,’VariableNames’,VNAMES);
Error using table (line 310)
Specify variable types as a string array or a cell array of character
vectors, such as ["string", "datetime", "double"].
i try to use in vtypes : {‘cat’}..{cat}…{"cat"} but it give me an error VNAMES={‘On’,’Trading’,’L_S’,’Stat’,’PROVA’,’Cap’,’Perc’,’Draw_Sys’};
cat=categorical({‘Fil’;’Stat’});
VTYPES=[{‘logical’},{‘string’},{‘string’},{‘double’},{‘double’},{‘cat’},{‘double’},{‘logical’}];
T=table(‘Size’,[nrows,numel(VNAMES)],’VariableTypes’,VTYPES,’VariableNames’,VNAMES);
Error using table (line 310)
Specify variable types as a string array or a cell array of character
vectors, such as ["string", "datetime", "double"].
i try to use in vtypes : {‘cat’}..{cat}…{"cat"} but it give me an error how use categorical in uitable MATLAB Answers — New Questions
Change size of input arguments without recompiling mex with codegen
I compiled a simple function with matlab coder. The function takes three input arguments: xvec is [nx,1], yvec is [ny,1] and zmat is [nx,ny]. All is good the first time I run the mex function, but if I subsequently change the size of one of the input arrays (say I change nx from nx=8 to nx=7), the function crashes. Of course I can compile again the code and it runs, but I really want to avoid recompilation every time I change the dimension of the inputs!
MWE here:
clear
clc
close all
nx = 8;
ny = 3;
xvec = linspace(0,1,nx)’;
yvec = linspace(0,1,ny)’;
zmat = xvec.^2+yvec’; % [nx,ny]
%size(zmat)
disp(‘Calling myfun…’)
res = myfun(xvec,yvec,zmat);
% MEX with codegen
disp(‘Compiling MEX…’)
cfg = coder.config(‘mex’);
cfg.GenerateReport = true;
codegen -config cfg myfun -args {xvec,yvec,zmat} -o myfun_mex
disp(‘Calling myfun_mex…’)
res_mex = myfun_mex(xvec,yvec,zmat);
err_mex = abs(res-res_mex)
and here is the function:
function res = myfun(x,y,z)
res = sum(x)+sum(y)+sum(sum(z));
end
First time, I compile and it runs OK. Then, if I set nx=7, it crashes with the following error message:
“`
Incorrect size for expression ‘x’: expected [8×1] but found [7×1].
Error in myfun_mex
Error in main (line 22)
res_mex = myfun_mex(xvec,yvec,zmat);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
“`
Any help is greatly appreciated, thanks!I compiled a simple function with matlab coder. The function takes three input arguments: xvec is [nx,1], yvec is [ny,1] and zmat is [nx,ny]. All is good the first time I run the mex function, but if I subsequently change the size of one of the input arrays (say I change nx from nx=8 to nx=7), the function crashes. Of course I can compile again the code and it runs, but I really want to avoid recompilation every time I change the dimension of the inputs!
MWE here:
clear
clc
close all
nx = 8;
ny = 3;
xvec = linspace(0,1,nx)’;
yvec = linspace(0,1,ny)’;
zmat = xvec.^2+yvec’; % [nx,ny]
%size(zmat)
disp(‘Calling myfun…’)
res = myfun(xvec,yvec,zmat);
% MEX with codegen
disp(‘Compiling MEX…’)
cfg = coder.config(‘mex’);
cfg.GenerateReport = true;
codegen -config cfg myfun -args {xvec,yvec,zmat} -o myfun_mex
disp(‘Calling myfun_mex…’)
res_mex = myfun_mex(xvec,yvec,zmat);
err_mex = abs(res-res_mex)
and here is the function:
function res = myfun(x,y,z)
res = sum(x)+sum(y)+sum(sum(z));
end
First time, I compile and it runs OK. Then, if I set nx=7, it crashes with the following error message:
“`
Incorrect size for expression ‘x’: expected [8×1] but found [7×1].
Error in myfun_mex
Error in main (line 22)
res_mex = myfun_mex(xvec,yvec,zmat);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
“`
Any help is greatly appreciated, thanks! I compiled a simple function with matlab coder. The function takes three input arguments: xvec is [nx,1], yvec is [ny,1] and zmat is [nx,ny]. All is good the first time I run the mex function, but if I subsequently change the size of one of the input arrays (say I change nx from nx=8 to nx=7), the function crashes. Of course I can compile again the code and it runs, but I really want to avoid recompilation every time I change the dimension of the inputs!
MWE here:
clear
clc
close all
nx = 8;
ny = 3;
xvec = linspace(0,1,nx)’;
yvec = linspace(0,1,ny)’;
zmat = xvec.^2+yvec’; % [nx,ny]
%size(zmat)
disp(‘Calling myfun…’)
res = myfun(xvec,yvec,zmat);
% MEX with codegen
disp(‘Compiling MEX…’)
cfg = coder.config(‘mex’);
cfg.GenerateReport = true;
codegen -config cfg myfun -args {xvec,yvec,zmat} -o myfun_mex
disp(‘Calling myfun_mex…’)
res_mex = myfun_mex(xvec,yvec,zmat);
err_mex = abs(res-res_mex)
and here is the function:
function res = myfun(x,y,z)
res = sum(x)+sum(y)+sum(sum(z));
end
First time, I compile and it runs OK. Then, if I set nx=7, it crashes with the following error message:
“`
Incorrect size for expression ‘x’: expected [8×1] but found [7×1].
Error in myfun_mex
Error in main (line 22)
res_mex = myfun_mex(xvec,yvec,zmat);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
“`
Any help is greatly appreciated, thanks! codegen, function, mex MATLAB Answers — New Questions
External mode option not showing on simulink matlab 2020a
I want to interface arduino with simulink in external mode but i didnt find external mode option in simulink.Please help me to find that ‘external mode’option in main menu.I want to interface arduino with simulink in external mode but i didnt find external mode option in simulink.Please help me to find that ‘external mode’option in main menu. I want to interface arduino with simulink in external mode but i didnt find external mode option in simulink.Please help me to find that ‘external mode’option in main menu. simulink, matlab MATLAB Answers — New Questions
Matlab no muestra el gráfico de mi codigo
Estoy usando matlab online y nunca he tenido problemas con las graficas ni codigo, todo me funcionaba perfecto, hace unos dias hice un codigo que me devuelve una grafica, pero hoy ejecute el mismo codigo sin ningun cambio y no me devuelve la grafica, solo me muestra el pnale de grafica pero en blanco
tengo el siguiente codigo:
close all
clear all
clc
% Duración y frecuencia de muestreo
duration = 5;
Fs = 44100;
t = linspace(0, duration, duration * Fs);
% crossfade con maximo de 1
crossfade = exponentialFunction(t, 1, 1);
% Señal generada aleatoriamente adicional para producir el efecto de crossfade
autoGeneratedSignal = cos(2 * pi * 1000 * t); % Ajusta la frecuencia y forma de la señal
% Aplicar crossfade a las dos señales
signal1 = autoGeneratedSignal .* crossfade(2, :);
signal2 = sin(2 * pi * 500 * t) .* crossfade(1, :); % Genera otra señal, puedes ajustar la frecuencia
% Sumar las señales para obtener el resultado del crossfade
result = signal2 + signal1;
% Visualizar el resultado
figure;
subplot(3, 1, 1);
plot(t, signal1, ‘LineWidth’, 2);
title(‘Señal Generada con Crossfade’);
subplot(3, 1, 2);
plot(t, signal2, ‘LineWidth’, 2);
title(‘Otra Señal con Crossfade’);
subplot(3, 1, 3);
plot(t, result, ‘LineWidth’, 2);
title(‘Resultado del Crossfade’);
% Reproducir el resultado
sound(result, Fs);
function y = exponentialFunction(t, decayRate, growthRate)
% Genera una función exponencial decreciente y creciente con un valor máximo de 1.
% Parámetros:
% t: Vector de tiempo
% decayRate: Tasa de decrecimiento exponencial (debe ser un número positivo)
% growthRate: Tasa de crecimiento exponencial (debe ser un número positivo)
% Asegúrate de que los parámetros sean válidos
if decayRate <= 0 || growthRate <= 0
error(‘Las tasas de decrecimiento y crecimiento deben ser números positivos.’);
end
% Genera las funciones exponenciales
decayFunction = exp(-decayRate * t);
growthFunction = 1 – exp(-growthRate * t);
% Normaliza las funciones para tener un valor máximo de 1
decayFunction = decayFunction / max(decayFunction);
growthFunction = growthFunction / max(growthFunction);
% Combina las funciones
y = [decayFunction; growthFunction];
endEstoy usando matlab online y nunca he tenido problemas con las graficas ni codigo, todo me funcionaba perfecto, hace unos dias hice un codigo que me devuelve una grafica, pero hoy ejecute el mismo codigo sin ningun cambio y no me devuelve la grafica, solo me muestra el pnale de grafica pero en blanco
tengo el siguiente codigo:
close all
clear all
clc
% Duración y frecuencia de muestreo
duration = 5;
Fs = 44100;
t = linspace(0, duration, duration * Fs);
% crossfade con maximo de 1
crossfade = exponentialFunction(t, 1, 1);
% Señal generada aleatoriamente adicional para producir el efecto de crossfade
autoGeneratedSignal = cos(2 * pi * 1000 * t); % Ajusta la frecuencia y forma de la señal
% Aplicar crossfade a las dos señales
signal1 = autoGeneratedSignal .* crossfade(2, :);
signal2 = sin(2 * pi * 500 * t) .* crossfade(1, :); % Genera otra señal, puedes ajustar la frecuencia
% Sumar las señales para obtener el resultado del crossfade
result = signal2 + signal1;
% Visualizar el resultado
figure;
subplot(3, 1, 1);
plot(t, signal1, ‘LineWidth’, 2);
title(‘Señal Generada con Crossfade’);
subplot(3, 1, 2);
plot(t, signal2, ‘LineWidth’, 2);
title(‘Otra Señal con Crossfade’);
subplot(3, 1, 3);
plot(t, result, ‘LineWidth’, 2);
title(‘Resultado del Crossfade’);
% Reproducir el resultado
sound(result, Fs);
function y = exponentialFunction(t, decayRate, growthRate)
% Genera una función exponencial decreciente y creciente con un valor máximo de 1.
% Parámetros:
% t: Vector de tiempo
% decayRate: Tasa de decrecimiento exponencial (debe ser un número positivo)
% growthRate: Tasa de crecimiento exponencial (debe ser un número positivo)
% Asegúrate de que los parámetros sean válidos
if decayRate <= 0 || growthRate <= 0
error(‘Las tasas de decrecimiento y crecimiento deben ser números positivos.’);
end
% Genera las funciones exponenciales
decayFunction = exp(-decayRate * t);
growthFunction = 1 – exp(-growthRate * t);
% Normaliza las funciones para tener un valor máximo de 1
decayFunction = decayFunction / max(decayFunction);
growthFunction = growthFunction / max(growthFunction);
% Combina las funciones
y = [decayFunction; growthFunction];
end Estoy usando matlab online y nunca he tenido problemas con las graficas ni codigo, todo me funcionaba perfecto, hace unos dias hice un codigo que me devuelve una grafica, pero hoy ejecute el mismo codigo sin ningun cambio y no me devuelve la grafica, solo me muestra el pnale de grafica pero en blanco
tengo el siguiente codigo:
close all
clear all
clc
% Duración y frecuencia de muestreo
duration = 5;
Fs = 44100;
t = linspace(0, duration, duration * Fs);
% crossfade con maximo de 1
crossfade = exponentialFunction(t, 1, 1);
% Señal generada aleatoriamente adicional para producir el efecto de crossfade
autoGeneratedSignal = cos(2 * pi * 1000 * t); % Ajusta la frecuencia y forma de la señal
% Aplicar crossfade a las dos señales
signal1 = autoGeneratedSignal .* crossfade(2, :);
signal2 = sin(2 * pi * 500 * t) .* crossfade(1, :); % Genera otra señal, puedes ajustar la frecuencia
% Sumar las señales para obtener el resultado del crossfade
result = signal2 + signal1;
% Visualizar el resultado
figure;
subplot(3, 1, 1);
plot(t, signal1, ‘LineWidth’, 2);
title(‘Señal Generada con Crossfade’);
subplot(3, 1, 2);
plot(t, signal2, ‘LineWidth’, 2);
title(‘Otra Señal con Crossfade’);
subplot(3, 1, 3);
plot(t, result, ‘LineWidth’, 2);
title(‘Resultado del Crossfade’);
% Reproducir el resultado
sound(result, Fs);
function y = exponentialFunction(t, decayRate, growthRate)
% Genera una función exponencial decreciente y creciente con un valor máximo de 1.
% Parámetros:
% t: Vector de tiempo
% decayRate: Tasa de decrecimiento exponencial (debe ser un número positivo)
% growthRate: Tasa de crecimiento exponencial (debe ser un número positivo)
% Asegúrate de que los parámetros sean válidos
if decayRate <= 0 || growthRate <= 0
error(‘Las tasas de decrecimiento y crecimiento deben ser números positivos.’);
end
% Genera las funciones exponenciales
decayFunction = exp(-decayRate * t);
growthFunction = 1 – exp(-growthRate * t);
% Normaliza las funciones para tener un valor máximo de 1
decayFunction = decayFunction / max(decayFunction);
growthFunction = growthFunction / max(growthFunction);
% Combina las funciones
y = [decayFunction; growthFunction];
end matlab online MATLAB Answers — New Questions
Vehicle Dynamics 3DOF Single Track Block doesn’t seem to include drag equations.
For the Vehicle Body 3 DOF block in the Vehicle Dynamics Blockset, I’ve configured it to run in single track mode. The documentation includes equations for drag forces under the dual track section, but not the single track section, which led me to believe that the drag forces are only relevant for the dual track block.
This does not seem to be the case, as I’m observing the drag forces in the output of the single track block to be nonzero. It makes sense that drag would be accounted for in both single track and dual track modes, but why then are the drag forces only described in the dual track equations?
Furthermore, the single track documentation does mention drag forces, saying that external forces = drag forces + input forces:
But then when I observe the external body forces as output by the block, they are always 0 despite the drag forces being nonzero. Seems like there might be a term overload with "external forces" referring both to the external input forces as well as the drag + input combined force.
External force input:
What I thought would be the computed external force output (drag + input forces), but is always 0 when input force is 0:For the Vehicle Body 3 DOF block in the Vehicle Dynamics Blockset, I’ve configured it to run in single track mode. The documentation includes equations for drag forces under the dual track section, but not the single track section, which led me to believe that the drag forces are only relevant for the dual track block.
This does not seem to be the case, as I’m observing the drag forces in the output of the single track block to be nonzero. It makes sense that drag would be accounted for in both single track and dual track modes, but why then are the drag forces only described in the dual track equations?
Furthermore, the single track documentation does mention drag forces, saying that external forces = drag forces + input forces:
But then when I observe the external body forces as output by the block, they are always 0 despite the drag forces being nonzero. Seems like there might be a term overload with "external forces" referring both to the external input forces as well as the drag + input combined force.
External force input:
What I thought would be the computed external force output (drag + input forces), but is always 0 when input force is 0: For the Vehicle Body 3 DOF block in the Vehicle Dynamics Blockset, I’ve configured it to run in single track mode. The documentation includes equations for drag forces under the dual track section, but not the single track section, which led me to believe that the drag forces are only relevant for the dual track block.
This does not seem to be the case, as I’m observing the drag forces in the output of the single track block to be nonzero. It makes sense that drag would be accounted for in both single track and dual track modes, but why then are the drag forces only described in the dual track equations?
Furthermore, the single track documentation does mention drag forces, saying that external forces = drag forces + input forces:
But then when I observe the external body forces as output by the block, they are always 0 despite the drag forces being nonzero. Seems like there might be a term overload with "external forces" referring both to the external input forces as well as the drag + input combined force.
External force input:
What I thought would be the computed external force output (drag + input forces), but is always 0 when input force is 0: simulink, vehicle dynamics MATLAB Answers — New Questions