Category: News
Reconstructing signal using the IFFT
Hello, I am using the FFt to convert a time series signal into images by reshaping the matrix (N*N). But i am having hard time to get the original signal back from the images. IS it because in fft i am considering only the magnitude of the signal not the phase of the signal ? Is there any way to solve this proble. May be using STFT ot any kind of other techniquesHello, I am using the FFt to convert a time series signal into images by reshaping the matrix (N*N). But i am having hard time to get the original signal back from the images. IS it because in fft i am considering only the magnitude of the signal not the phase of the signal ? Is there any way to solve this proble. May be using STFT ot any kind of other techniques Hello, I am using the FFt to convert a time series signal into images by reshaping the matrix (N*N). But i am having hard time to get the original signal back from the images. IS it because in fft i am considering only the magnitude of the signal not the phase of the signal ? Is there any way to solve this proble. May be using STFT ot any kind of other techniques fft, ifft MATLAB Answers — New Questions
How to plot a function using gradient descent method?
— – #optimisation, #convex optimization, #gradient descent method, —obviously homework— MATLAB Answers — New Questions
BOOSTXL-DRV8320H interface with LaunchXL-F280049C
Dear Community,
I am using custom driver board which have BOOSTXL-DRV8320H and wants interface with LAUNCHXL-F280049C for BLDC Senseless motor.
I am refering this example >>openExample(‘mcb/SensorlessFocFOSMOExample’)
Does DRV8320H needs any driver code to integrate with Matlab code?
How to set nFAULT condition to observe fault?
What should be the interface required for hardware connection?
What should be the standard deadband limit ePWM. Currently RED,FED set to 15 period cycle.
Is there any way to observe these PWM waveforms?
Thanks.Dear Community,
I am using custom driver board which have BOOSTXL-DRV8320H and wants interface with LAUNCHXL-F280049C for BLDC Senseless motor.
I am refering this example >>openExample(‘mcb/SensorlessFocFOSMOExample’)
Does DRV8320H needs any driver code to integrate with Matlab code?
How to set nFAULT condition to observe fault?
What should be the interface required for hardware connection?
What should be the standard deadband limit ePWM. Currently RED,FED set to 15 period cycle.
Is there any way to observe these PWM waveforms?
Thanks. Dear Community,
I am using custom driver board which have BOOSTXL-DRV8320H and wants interface with LAUNCHXL-F280049C for BLDC Senseless motor.
I am refering this example >>openExample(‘mcb/SensorlessFocFOSMOExample’)
Does DRV8320H needs any driver code to integrate with Matlab code?
How to set nFAULT condition to observe fault?
What should be the interface required for hardware connection?
What should be the standard deadband limit ePWM. Currently RED,FED set to 15 period cycle.
Is there any way to observe these PWM waveforms?
Thanks. motor control blockset, bldc MATLAB Answers — New Questions
problem in integrating pre trined ANN regression model in appdesigner
Hi
i want to use a pre trained ANN regression model in the app designer, but i did not find out how to do that.
any help…Hi
i want to use a pre trained ANN regression model in the app designer, but i did not find out how to do that.
any help… Hi
i want to use a pre trained ANN regression model in the app designer, but i did not find out how to do that.
any help… kojiro saito MATLAB Answers — New Questions
How can I get the coefficients using the fir filter and hamming window in y = decimate(x,r,”fir”) , so I can simulate this function output in another program?
In using this function in matlab y = decimate(x,r,"fir"), I have got an output that I want to create in another program without using matlab. Where can I get the specs, coefficients, and weights to replicate this fir filter and hamming window?In using this function in matlab y = decimate(x,r,"fir"), I have got an output that I want to create in another program without using matlab. Where can I get the specs, coefficients, and weights to replicate this fir filter and hamming window? In using this function in matlab y = decimate(x,r,"fir"), I have got an output that I want to create in another program without using matlab. Where can I get the specs, coefficients, and weights to replicate this fir filter and hamming window? fir filter, hamming window, decimate MATLAB Answers — New Questions
app designer Control chart-How to construct shewhart control charts in app designer?
Hi all,
can any one suggest me, how to use "controlchart" function in appdesigner?Hi all,
can any one suggest me, how to use "controlchart" function in appdesigner? Hi all,
can any one suggest me, how to use "controlchart" function in appdesigner? app designer, control chart, shewhart control charts, statistics tool box MATLAB Answers — New Questions
Problem in exporting function expression
Dear all
I get a function cd(x,y).I would like to export this function expression like this form:x^2+y^3… .What shall I do?
Part of a function expression:Dear all
I get a function cd(x,y).I would like to export this function expression like this form:x^2+y^3… .What shall I do?
Part of a function expression: Dear all
I get a function cd(x,y).I would like to export this function expression like this form:x^2+y^3… .What shall I do?
Part of a function expression: export, function, save, fprintf, print MATLAB Answers — New Questions
Link external program (HEC HMS) and optimize the parameters using Matlab
I want to automate my calibration and validation process in my hydrological model (HEC HMS). I want to do optimization code in matlab, where it can reiterate the parameters until it achieve the best error index. I already have a setup of the HMS model on my area, I am on the process of calibrating my parameters.I want to automate my calibration and validation process in my hydrological model (HEC HMS). I want to do optimization code in matlab, where it can reiterate the parameters until it achieve the best error index. I already have a setup of the HMS model on my area, I am on the process of calibrating my parameters. I want to automate my calibration and validation process in my hydrological model (HEC HMS). I want to do optimization code in matlab, where it can reiterate the parameters until it achieve the best error index. I already have a setup of the HMS model on my area, I am on the process of calibrating my parameters. hydrology, hec, hms, hec hms, optimization, external program MATLAB Answers — New Questions
Why do we have to provide the jacobians at the Non-linear MPC of Matlab?
Hello,
this is more of a theory question but I would greatly appreciate if you could cite good sources with the theory behind my following question:
Why do we have to define (either numerically or analytically) the jacobians for the NMPC in Matlab?
I can understand that the Jacobian for the A, B and C matrices are for the linearization of the prediction model, but I don’t really understand why we need Jacobians for the Cost function and the Constraints as well.Hello,
this is more of a theory question but I would greatly appreciate if you could cite good sources with the theory behind my following question:
Why do we have to define (either numerically or analytically) the jacobians for the NMPC in Matlab?
I can understand that the Jacobian for the A, B and C matrices are for the linearization of the prediction model, but I don’t really understand why we need Jacobians for the Cost function and the Constraints as well. Hello,
this is more of a theory question but I would greatly appreciate if you could cite good sources with the theory behind my following question:
Why do we have to define (either numerically or analytically) the jacobians for the NMPC in Matlab?
I can understand that the Jacobian for the A, B and C matrices are for the linearization of the prediction model, but I don’t really understand why we need Jacobians for the Cost function and the Constraints as well. nmpc MATLAB Answers — New Questions
run Simscape HDL Workflow Advisor from script
Hi
I am currently working on automating my workflow with Simscape and the HDL Coder. Unfortunately, I cannot find an option to run and configure the Simscape HDL Workflow Advisor (sschdladvisor) from the command line. Is there any way to do this?
Thanks
MarcoHi
I am currently working on automating my workflow with Simscape and the HDL Coder. Unfortunately, I cannot find an option to run and configure the Simscape HDL Workflow Advisor (sschdladvisor) from the command line. Is there any way to do this?
Thanks
Marco Hi
I am currently working on automating my workflow with Simscape and the HDL Coder. Unfortunately, I cannot find an option to run and configure the Simscape HDL Workflow Advisor (sschdladvisor) from the command line. Is there any way to do this?
Thanks
Marco simscape, hdl-coder, workflow advisor MATLAB Answers — New Questions
why i can’t get same plot when i change Real to Im?
i plot the real one but when i change the plot for abs i can get the abs why i can’t get that of this function
0.2e1 * (0.4e1 * exp((-8 * t + 2 * x)) + 0.9e1 * exp((-27 * t + 3 * x)) + 0.25e2 * exp((-35 * t + 5 * x + 2))) / (exp(0.2e1) + exp((-8 * t + 2 * x)) + exp((-27 * t + 3 * x)) + exp((-35 * t + 5 * x + 2))) – 0.2e1 * (0.2e1 * exp((-8 * t + 2 * x)) + 0.3e1 * exp((-27 * t + 3 * x)) + 0.5e1 * exp((-35 * t + 5 * x + 2))) ^ 2 / (exp(0.2e1) + exp((-8 * t + 2 * x)) + exp((-27 * t + 3 * x)) + exp((-35 * t + 5 * x + 2))) ^ 2
and my code for ploting is
abs(0.2e1 .* (0.4e1 * exp((-8 * t + 2 * x)) + 0.9e1 .* exp((-27 * t + 3 * x)) + 0.25e2 .* exp((-35 * t + 5 * x + 2))) ./ (exp(0.2e1) + exp((-8 * t + 2 * x)) + exp((-27 * t + 3 * x)) + exp((-35 * t + 5 * x + 2))) – 0.2e1 * (0.2e1 .* exp((-8 * t + 2 * x)) + 0.3e1 .* exp((-27 * t + 3 * x)) + 0.5e1 .* exp((-35 * t + 5 * x + 2))) .^ 2 ./ (exp(0.2e1) + exp((-8 * t + 2 * x)) + exp((-27 * t + 3 .* x)) + exp((-35 * t + 5 * x + 2))) .^ 2).^2i plot the real one but when i change the plot for abs i can get the abs why i can’t get that of this function
0.2e1 * (0.4e1 * exp((-8 * t + 2 * x)) + 0.9e1 * exp((-27 * t + 3 * x)) + 0.25e2 * exp((-35 * t + 5 * x + 2))) / (exp(0.2e1) + exp((-8 * t + 2 * x)) + exp((-27 * t + 3 * x)) + exp((-35 * t + 5 * x + 2))) – 0.2e1 * (0.2e1 * exp((-8 * t + 2 * x)) + 0.3e1 * exp((-27 * t + 3 * x)) + 0.5e1 * exp((-35 * t + 5 * x + 2))) ^ 2 / (exp(0.2e1) + exp((-8 * t + 2 * x)) + exp((-27 * t + 3 * x)) + exp((-35 * t + 5 * x + 2))) ^ 2
and my code for ploting is
abs(0.2e1 .* (0.4e1 * exp((-8 * t + 2 * x)) + 0.9e1 .* exp((-27 * t + 3 * x)) + 0.25e2 .* exp((-35 * t + 5 * x + 2))) ./ (exp(0.2e1) + exp((-8 * t + 2 * x)) + exp((-27 * t + 3 * x)) + exp((-35 * t + 5 * x + 2))) – 0.2e1 * (0.2e1 .* exp((-8 * t + 2 * x)) + 0.3e1 .* exp((-27 * t + 3 * x)) + 0.5e1 .* exp((-35 * t + 5 * x + 2))) .^ 2 ./ (exp(0.2e1) + exp((-8 * t + 2 * x)) + exp((-27 * t + 3 .* x)) + exp((-35 * t + 5 * x + 2))) .^ 2).^2 i plot the real one but when i change the plot for abs i can get the abs why i can’t get that of this function
0.2e1 * (0.4e1 * exp((-8 * t + 2 * x)) + 0.9e1 * exp((-27 * t + 3 * x)) + 0.25e2 * exp((-35 * t + 5 * x + 2))) / (exp(0.2e1) + exp((-8 * t + 2 * x)) + exp((-27 * t + 3 * x)) + exp((-35 * t + 5 * x + 2))) – 0.2e1 * (0.2e1 * exp((-8 * t + 2 * x)) + 0.3e1 * exp((-27 * t + 3 * x)) + 0.5e1 * exp((-35 * t + 5 * x + 2))) ^ 2 / (exp(0.2e1) + exp((-8 * t + 2 * x)) + exp((-27 * t + 3 * x)) + exp((-35 * t + 5 * x + 2))) ^ 2
and my code for ploting is
abs(0.2e1 .* (0.4e1 * exp((-8 * t + 2 * x)) + 0.9e1 .* exp((-27 * t + 3 * x)) + 0.25e2 .* exp((-35 * t + 5 * x + 2))) ./ (exp(0.2e1) + exp((-8 * t + 2 * x)) + exp((-27 * t + 3 * x)) + exp((-35 * t + 5 * x + 2))) – 0.2e1 * (0.2e1 .* exp((-8 * t + 2 * x)) + 0.3e1 .* exp((-27 * t + 3 * x)) + 0.5e1 .* exp((-35 * t + 5 * x + 2))) .^ 2 ./ (exp(0.2e1) + exp((-8 * t + 2 * x)) + exp((-27 * t + 3 .* x)) + exp((-35 * t + 5 * x + 2))) .^ 2).^2 plotting, 3d plots MATLAB Answers — New Questions
Roadrunner: XML validation failed
an error occurs when trying to export as xodr file.an error occurs when trying to export as xodr file. an error occurs when trying to export as xodr file. export, xml, xodr MATLAB Answers — New Questions
Opening text document and sending the info over serial port
I have a text document, called transition.txt, that has this inside it.
L,R,D’,B,U,D,F’,R,B’,L’,B2,R,F2,D2,F,L’,U2,L,U2,L,B2,L’,B2,L2,U2,L2,R2,U2,B2,U2
I need to send it to my arduino. Not sure what the code should do on the Matlab side. Also, how would I make sure the information got to the arduino in the way I wanted it to?
Here is my arduino code.
const size_t maxCommandNumber = 50;
const size_t maxCommandSize = 3 * maxCommandNumber; // if commands fit on 2 characters and a comma, this is enough for maxCommandNumber commands
char receivedChars[maxCommandSize + 1]; // +1 for trailing null char required by cStrings
const char endMarker = ‘n’;
void func_L(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_Lp(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_L2(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_R(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_Rp(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_R2(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_D(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_Dp(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_D2(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_B(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_Bp(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_B2(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_U(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_Up(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_U2(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_F(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_Fp(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_F2(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_unknown(const char* s) {Serial.print(F("Unknown commmand: ")); Serial.println(s);}
struct {
const char* label;
void (*func)(const char*);
} keys[] = {
{"L", func_L},
{"L’", func_Lp},
{"L2", func_L2},
{"R", func_R},
{"R’", func_Rp},
{"R2", func_R2},
{"D", func_D},
{"D’", func_Dp},
{"D2", func_D2},
{"B", func_B},
{"B’", func_Bp},
{"B2", func_B2},
{"U", func_U},
{"U’", func_Up},
{"U2", func_U2},
{"F", func_F},
{"F’", func_Fp},
{"F2", func_F2},
};
const size_t nbKeys = sizeof keys / sizeof keys[0];
bool findAndExecute(const char* s)
{
bool success = false;
for (size_t i = 0; i < nbKeys; i++)
if (!strcmp(s, keys[i].label)) {
keys[i].func(s);
success = true;
break;
}
if (!success) func_unknown(s);
return success;
}
bool commandAvailable()
{
static size_t commandIndex = 0;
static bool awaitEndMarkerError = false;
int incomingByte = Serial.read();
bool commandComplete = false;
if (incomingByte != -1) { // read returns -1 if there is nothing to read (faster than using available)
if (awaitEndMarkerError) {
if (incomingByte == endMarker) {
awaitEndMarkerError = false;
commandIndex = 0;
receivedChars[0] = ”; // discard what was there
commandComplete = true; // if we want to still notify the parser we got a command (here will be empty)
}
} else {
char incomingCharacter = incomingByte; // grab LSB as a char
if (incomingByte != endMarker) {
if (commandIndex < maxCommandSize) {
if (!isspace(incomingCharacter)) { // discard all spaces. could also add a test to only keep A-Z and ‘ and 2, whatever is legit in the command language
receivedChars[commandIndex++] = incomingCharacter;
receivedChars[commandIndex] = ”; // always maintain a correct cString
}
} else {
Serial.println(F("ERROR: Command line too big. Discarded.nt-> increase maxCommandNumber or send shorter command lines."));
awaitEndMarkerError = true;
}
} else {
commandIndex = 0;
commandComplete = true;
}
}
}
return commandComplete;
}
bool handleCommand()
{
bool success = true;
const char* separators = ",";
Serial.print(F("nparsing : ")); Serial.println(receivedChars);
char* ptr = strtok(receivedChars, separators);
if (*ptr == ”) Serial.println(F("Error: empty command"));
else
while (ptr) {
success &= findAndExecute(ptr);
ptr = strtok(NULL, separators);
}
return success;
}
void setup() {
Serial.begin(115200);
}
void loop() {
if (commandAvailable())
if (! handleCommand())
Serial.println(F("Some commands were not recognized"));
}I have a text document, called transition.txt, that has this inside it.
L,R,D’,B,U,D,F’,R,B’,L’,B2,R,F2,D2,F,L’,U2,L,U2,L,B2,L’,B2,L2,U2,L2,R2,U2,B2,U2
I need to send it to my arduino. Not sure what the code should do on the Matlab side. Also, how would I make sure the information got to the arduino in the way I wanted it to?
Here is my arduino code.
const size_t maxCommandNumber = 50;
const size_t maxCommandSize = 3 * maxCommandNumber; // if commands fit on 2 characters and a comma, this is enough for maxCommandNumber commands
char receivedChars[maxCommandSize + 1]; // +1 for trailing null char required by cStrings
const char endMarker = ‘n’;
void func_L(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_Lp(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_L2(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_R(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_Rp(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_R2(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_D(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_Dp(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_D2(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_B(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_Bp(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_B2(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_U(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_Up(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_U2(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_F(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_Fp(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_F2(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_unknown(const char* s) {Serial.print(F("Unknown commmand: ")); Serial.println(s);}
struct {
const char* label;
void (*func)(const char*);
} keys[] = {
{"L", func_L},
{"L’", func_Lp},
{"L2", func_L2},
{"R", func_R},
{"R’", func_Rp},
{"R2", func_R2},
{"D", func_D},
{"D’", func_Dp},
{"D2", func_D2},
{"B", func_B},
{"B’", func_Bp},
{"B2", func_B2},
{"U", func_U},
{"U’", func_Up},
{"U2", func_U2},
{"F", func_F},
{"F’", func_Fp},
{"F2", func_F2},
};
const size_t nbKeys = sizeof keys / sizeof keys[0];
bool findAndExecute(const char* s)
{
bool success = false;
for (size_t i = 0; i < nbKeys; i++)
if (!strcmp(s, keys[i].label)) {
keys[i].func(s);
success = true;
break;
}
if (!success) func_unknown(s);
return success;
}
bool commandAvailable()
{
static size_t commandIndex = 0;
static bool awaitEndMarkerError = false;
int incomingByte = Serial.read();
bool commandComplete = false;
if (incomingByte != -1) { // read returns -1 if there is nothing to read (faster than using available)
if (awaitEndMarkerError) {
if (incomingByte == endMarker) {
awaitEndMarkerError = false;
commandIndex = 0;
receivedChars[0] = ”; // discard what was there
commandComplete = true; // if we want to still notify the parser we got a command (here will be empty)
}
} else {
char incomingCharacter = incomingByte; // grab LSB as a char
if (incomingByte != endMarker) {
if (commandIndex < maxCommandSize) {
if (!isspace(incomingCharacter)) { // discard all spaces. could also add a test to only keep A-Z and ‘ and 2, whatever is legit in the command language
receivedChars[commandIndex++] = incomingCharacter;
receivedChars[commandIndex] = ”; // always maintain a correct cString
}
} else {
Serial.println(F("ERROR: Command line too big. Discarded.nt-> increase maxCommandNumber or send shorter command lines."));
awaitEndMarkerError = true;
}
} else {
commandIndex = 0;
commandComplete = true;
}
}
}
return commandComplete;
}
bool handleCommand()
{
bool success = true;
const char* separators = ",";
Serial.print(F("nparsing : ")); Serial.println(receivedChars);
char* ptr = strtok(receivedChars, separators);
if (*ptr == ”) Serial.println(F("Error: empty command"));
else
while (ptr) {
success &= findAndExecute(ptr);
ptr = strtok(NULL, separators);
}
return success;
}
void setup() {
Serial.begin(115200);
}
void loop() {
if (commandAvailable())
if (! handleCommand())
Serial.println(F("Some commands were not recognized"));
} I have a text document, called transition.txt, that has this inside it.
L,R,D’,B,U,D,F’,R,B’,L’,B2,R,F2,D2,F,L’,U2,L,U2,L,B2,L’,B2,L2,U2,L2,R2,U2,B2,U2
I need to send it to my arduino. Not sure what the code should do on the Matlab side. Also, how would I make sure the information got to the arduino in the way I wanted it to?
Here is my arduino code.
const size_t maxCommandNumber = 50;
const size_t maxCommandSize = 3 * maxCommandNumber; // if commands fit on 2 characters and a comma, this is enough for maxCommandNumber commands
char receivedChars[maxCommandSize + 1]; // +1 for trailing null char required by cStrings
const char endMarker = ‘n’;
void func_L(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_Lp(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_L2(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_R(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_Rp(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_R2(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_D(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_Dp(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_D2(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_B(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_Bp(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_B2(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_U(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_Up(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_U2(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_F(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_Fp(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_F2(const char* s) {Serial.print(F("in Function ")); Serial.println(s);}
void func_unknown(const char* s) {Serial.print(F("Unknown commmand: ")); Serial.println(s);}
struct {
const char* label;
void (*func)(const char*);
} keys[] = {
{"L", func_L},
{"L’", func_Lp},
{"L2", func_L2},
{"R", func_R},
{"R’", func_Rp},
{"R2", func_R2},
{"D", func_D},
{"D’", func_Dp},
{"D2", func_D2},
{"B", func_B},
{"B’", func_Bp},
{"B2", func_B2},
{"U", func_U},
{"U’", func_Up},
{"U2", func_U2},
{"F", func_F},
{"F’", func_Fp},
{"F2", func_F2},
};
const size_t nbKeys = sizeof keys / sizeof keys[0];
bool findAndExecute(const char* s)
{
bool success = false;
for (size_t i = 0; i < nbKeys; i++)
if (!strcmp(s, keys[i].label)) {
keys[i].func(s);
success = true;
break;
}
if (!success) func_unknown(s);
return success;
}
bool commandAvailable()
{
static size_t commandIndex = 0;
static bool awaitEndMarkerError = false;
int incomingByte = Serial.read();
bool commandComplete = false;
if (incomingByte != -1) { // read returns -1 if there is nothing to read (faster than using available)
if (awaitEndMarkerError) {
if (incomingByte == endMarker) {
awaitEndMarkerError = false;
commandIndex = 0;
receivedChars[0] = ”; // discard what was there
commandComplete = true; // if we want to still notify the parser we got a command (here will be empty)
}
} else {
char incomingCharacter = incomingByte; // grab LSB as a char
if (incomingByte != endMarker) {
if (commandIndex < maxCommandSize) {
if (!isspace(incomingCharacter)) { // discard all spaces. could also add a test to only keep A-Z and ‘ and 2, whatever is legit in the command language
receivedChars[commandIndex++] = incomingCharacter;
receivedChars[commandIndex] = ”; // always maintain a correct cString
}
} else {
Serial.println(F("ERROR: Command line too big. Discarded.nt-> increase maxCommandNumber or send shorter command lines."));
awaitEndMarkerError = true;
}
} else {
commandIndex = 0;
commandComplete = true;
}
}
}
return commandComplete;
}
bool handleCommand()
{
bool success = true;
const char* separators = ",";
Serial.print(F("nparsing : ")); Serial.println(receivedChars);
char* ptr = strtok(receivedChars, separators);
if (*ptr == ”) Serial.println(F("Error: empty command"));
else
while (ptr) {
success &= findAndExecute(ptr);
ptr = strtok(NULL, separators);
}
return success;
}
void setup() {
Serial.begin(115200);
}
void loop() {
if (commandAvailable())
if (! handleCommand())
Serial.println(F("Some commands were not recognized"));
} arduino, serial, send MATLAB Answers — New Questions
Create boundaries in an image based on porosity
Hi I am trying to create a boundary in my image between 3 regions of different porosities. I have an algorithm which tells me the porosity of the whole image and when I give it different parts of this image it gives me different porosity values, but I am not sure how to apply that to create the boundaries I want. Please help. Here is the binary image and roughly what I’m trying to do.Hi I am trying to create a boundary in my image between 3 regions of different porosities. I have an algorithm which tells me the porosity of the whole image and when I give it different parts of this image it gives me different porosity values, but I am not sure how to apply that to create the boundaries I want. Please help. Here is the binary image and roughly what I’m trying to do. Hi I am trying to create a boundary in my image between 3 regions of different porosities. I have an algorithm which tells me the porosity of the whole image and when I give it different parts of this image it gives me different porosity values, but I am not sure how to apply that to create the boundaries I want. Please help. Here is the binary image and roughly what I’m trying to do. image segmentation, pore distribution MATLAB Answers — New Questions
Dividing a number by a column matrix in Matlab
For example if I were to type this in matlab:
>> 1/[1, 2 ,3]
There would be an error:
>> Error using /
Matrix dimensions must agree.
But if I were to type this in Matlab
>> 1/[1; 2; 3]
The answer would be:
[0 0 0.3333]
Why is Matlab doing this ?For example if I were to type this in matlab:
>> 1/[1, 2 ,3]
There would be an error:
>> Error using /
Matrix dimensions must agree.
But if I were to type this in Matlab
>> 1/[1; 2; 3]
The answer would be:
[0 0 0.3333]
Why is Matlab doing this ? For example if I were to type this in matlab:
>> 1/[1, 2 ,3]
There would be an error:
>> Error using /
Matrix dimensions must agree.
But if I were to type this in Matlab
>> 1/[1; 2; 3]
The answer would be:
[0 0 0.3333]
Why is Matlab doing this ? matlab, matrix MATLAB Answers — New Questions
Steady state error in DDPG control
I am trying to make some modifications in Control Water Level in a Tank Using a DDPG Agent example. I want to reduce sample time from 1.0 to 0.5, so I set Ts = 0.5. Consequently, I had to make adjustment on StopTrainingValue, i.e., changed its value from 2000 to 4000. The training process was successfully completed as it can be seen below.
But there is something unexpected happened: this modifications introduce a steady state error (or something similar to) that wasn’t there in the original example.
How to overcome this steady state error? Do I need to make additional adjustments, e.g. make changes to the structure of observations, reward function, actor/critic network, StopTrainingCriteria, etc?
Update:
This is the error I get using pre-trained agent (doTraining = false, no change on the original example)
This is the error I get using re-trained agent (doTraining = true, no change on the original example)I am trying to make some modifications in Control Water Level in a Tank Using a DDPG Agent example. I want to reduce sample time from 1.0 to 0.5, so I set Ts = 0.5. Consequently, I had to make adjustment on StopTrainingValue, i.e., changed its value from 2000 to 4000. The training process was successfully completed as it can be seen below.
But there is something unexpected happened: this modifications introduce a steady state error (or something similar to) that wasn’t there in the original example.
How to overcome this steady state error? Do I need to make additional adjustments, e.g. make changes to the structure of observations, reward function, actor/critic network, StopTrainingCriteria, etc?
Update:
This is the error I get using pre-trained agent (doTraining = false, no change on the original example)
This is the error I get using re-trained agent (doTraining = true, no change on the original example) I am trying to make some modifications in Control Water Level in a Tank Using a DDPG Agent example. I want to reduce sample time from 1.0 to 0.5, so I set Ts = 0.5. Consequently, I had to make adjustment on StopTrainingValue, i.e., changed its value from 2000 to 4000. The training process was successfully completed as it can be seen below.
But there is something unexpected happened: this modifications introduce a steady state error (or something similar to) that wasn’t there in the original example.
How to overcome this steady state error? Do I need to make additional adjustments, e.g. make changes to the structure of observations, reward function, actor/critic network, StopTrainingCriteria, etc?
Update:
This is the error I get using pre-trained agent (doTraining = false, no change on the original example)
This is the error I get using re-trained agent (doTraining = true, no change on the original example) control, reinforcement learning, deep learning MATLAB Answers — New Questions
How to include complex numbers in fprintf function?
lambda = [1.064e-6];
R = [30];
w=[0.001];
q = (1./R- i* lambda./pi./w.^2).^(-1);
a=1;
p=1;
m=1;
probe_r=linspace(0,0.003,100);
probe_theta=linspace(0,0.003,100);
rseed=[0*max(w):max(w)/30:3*max(w)];
thetaseed=[0:360]*pi/180;
[r,theta]=meshgrid(rseed,thetaseed);
E=LaguerreGaussianE([p,m,q,lambda,a],r,theta);
V=interp2(r,theta,E,probe_r,probe_theta);
column_names = {‘r’, ‘theta’, ‘V’};
fid = fopen(‘fidtext.txt’,’wt’);
fprintf(fid, ‘%s ‘, column_names{:});
fprintf(fid, ‘n’);
block_of_data = [probe_r, probe_theta, V];
fmt = repmat(‘%15g ‘, 1, 3);
fmt(end:end+1) = ‘n’;
fprintf(fid, fmt, block_of_data.’);
fclose(fid);
With the current code I have I get a .txt file of only the real numbers from my function V along with the values of probe_r and probe_theta. How do I alter this to produce both the real and complex numbers as a 3 column .txt file of r, theta and V as I am unable to see a formatSpec to include complex numbers.lambda = [1.064e-6];
R = [30];
w=[0.001];
q = (1./R- i* lambda./pi./w.^2).^(-1);
a=1;
p=1;
m=1;
probe_r=linspace(0,0.003,100);
probe_theta=linspace(0,0.003,100);
rseed=[0*max(w):max(w)/30:3*max(w)];
thetaseed=[0:360]*pi/180;
[r,theta]=meshgrid(rseed,thetaseed);
E=LaguerreGaussianE([p,m,q,lambda,a],r,theta);
V=interp2(r,theta,E,probe_r,probe_theta);
column_names = {‘r’, ‘theta’, ‘V’};
fid = fopen(‘fidtext.txt’,’wt’);
fprintf(fid, ‘%s ‘, column_names{:});
fprintf(fid, ‘n’);
block_of_data = [probe_r, probe_theta, V];
fmt = repmat(‘%15g ‘, 1, 3);
fmt(end:end+1) = ‘n’;
fprintf(fid, fmt, block_of_data.’);
fclose(fid);
With the current code I have I get a .txt file of only the real numbers from my function V along with the values of probe_r and probe_theta. How do I alter this to produce both the real and complex numbers as a 3 column .txt file of r, theta and V as I am unable to see a formatSpec to include complex numbers. lambda = [1.064e-6];
R = [30];
w=[0.001];
q = (1./R- i* lambda./pi./w.^2).^(-1);
a=1;
p=1;
m=1;
probe_r=linspace(0,0.003,100);
probe_theta=linspace(0,0.003,100);
rseed=[0*max(w):max(w)/30:3*max(w)];
thetaseed=[0:360]*pi/180;
[r,theta]=meshgrid(rseed,thetaseed);
E=LaguerreGaussianE([p,m,q,lambda,a],r,theta);
V=interp2(r,theta,E,probe_r,probe_theta);
column_names = {‘r’, ‘theta’, ‘V’};
fid = fopen(‘fidtext.txt’,’wt’);
fprintf(fid, ‘%s ‘, column_names{:});
fprintf(fid, ‘n’);
block_of_data = [probe_r, probe_theta, V];
fmt = repmat(‘%15g ‘, 1, 3);
fmt(end:end+1) = ‘n’;
fprintf(fid, fmt, block_of_data.’);
fclose(fid);
With the current code I have I get a .txt file of only the real numbers from my function V along with the values of probe_r and probe_theta. How do I alter this to produce both the real and complex numbers as a 3 column .txt file of r, theta and V as I am unable to see a formatSpec to include complex numbers. fprintf, complex numbers MATLAB Answers — New Questions
Why does the “Test Connection” for Bluetooth fail in the hardware setup screen for the Arduino support package on macOS versions 12, 13 and 14 ?
Issue:
Why does the "Test Connection" for Bluetooth fail in the hardware setup screen for the Arduino support package on macOS versions 12, 13 and 14?
I am using an Arduino Uno with an HC-05 Bluetooth module, intending to integrate it with the MATLAB Support Package for Arduino Hardware on my Mac running Ventura OS 13. While I can successfully program the board via the hardware setup screen, the "Test Connection" button consistently triggers a prompt outside of the MATLAB window requesting a device connection. Despite clicking "Connect" on this prompt, the test connection fails in the hardware setup screen, preventing further progress.
This issue also occurs on macOS 12 Monterey and macOS 14 Sonoma.
Prompt:
Test Connection failure:Issue:
Why does the "Test Connection" for Bluetooth fail in the hardware setup screen for the Arduino support package on macOS versions 12, 13 and 14?
I am using an Arduino Uno with an HC-05 Bluetooth module, intending to integrate it with the MATLAB Support Package for Arduino Hardware on my Mac running Ventura OS 13. While I can successfully program the board via the hardware setup screen, the "Test Connection" button consistently triggers a prompt outside of the MATLAB window requesting a device connection. Despite clicking "Connect" on this prompt, the test connection fails in the hardware setup screen, preventing further progress.
This issue also occurs on macOS 12 Monterey and macOS 14 Sonoma.
Prompt:
Test Connection failure: Issue:
Why does the "Test Connection" for Bluetooth fail in the hardware setup screen for the Arduino support package on macOS versions 12, 13 and 14?
I am using an Arduino Uno with an HC-05 Bluetooth module, intending to integrate it with the MATLAB Support Package for Arduino Hardware on my Mac running Ventura OS 13. While I can successfully program the board via the hardware setup screen, the "Test Connection" button consistently triggers a prompt outside of the MATLAB window requesting a device connection. Despite clicking "Connect" on this prompt, the test connection fails in the hardware setup screen, preventing further progress.
This issue also occurs on macOS 12 Monterey and macOS 14 Sonoma.
Prompt:
Test Connection failure: arduino, mac MATLAB Answers — New Questions
Why am I getting a Complex signal mismatch error when using the Simscape power system FACT element – UPFC(phasor model)
I got the following error when I tried a simulink model (named UPFC compensated line) of a power system using only the Simscape powersystem specialised technology components.
Complex signal mismatch. Input port 1 of ‘UPFC_compensated_line/Unified Power Flow Controller (Phasor Type)/Power Components Modeling (Shunt & Series Converter)/Power Components modeling (Shunt Converter)/Demux1’ expects a signal of numeric type real. However, it is driven by a signal of numeric type complex
Component: Simulink | Category: Block error
Complex signal mismatch. Output port 1 of ‘UPFC_compensated_line/Unified Power Flow Controller (Phasor Type)/Power Components Modeling (Shunt & Series Converter)/Power Components modeling (Shunt Converter)/dq-axis model of 3-ph RL branch’ is a signal of numeric type complex. However, it is driving a signal of numeric type real
What might be the reason? Please help to resolve the problemI got the following error when I tried a simulink model (named UPFC compensated line) of a power system using only the Simscape powersystem specialised technology components.
Complex signal mismatch. Input port 1 of ‘UPFC_compensated_line/Unified Power Flow Controller (Phasor Type)/Power Components Modeling (Shunt & Series Converter)/Power Components modeling (Shunt Converter)/Demux1’ expects a signal of numeric type real. However, it is driven by a signal of numeric type complex
Component: Simulink | Category: Block error
Complex signal mismatch. Output port 1 of ‘UPFC_compensated_line/Unified Power Flow Controller (Phasor Type)/Power Components Modeling (Shunt & Series Converter)/Power Components modeling (Shunt Converter)/dq-axis model of 3-ph RL branch’ is a signal of numeric type complex. However, it is driving a signal of numeric type real
What might be the reason? Please help to resolve the problem I got the following error when I tried a simulink model (named UPFC compensated line) of a power system using only the Simscape powersystem specialised technology components.
Complex signal mismatch. Input port 1 of ‘UPFC_compensated_line/Unified Power Flow Controller (Phasor Type)/Power Components Modeling (Shunt & Series Converter)/Power Components modeling (Shunt Converter)/Demux1’ expects a signal of numeric type real. However, it is driven by a signal of numeric type complex
Component: Simulink | Category: Block error
Complex signal mismatch. Output port 1 of ‘UPFC_compensated_line/Unified Power Flow Controller (Phasor Type)/Power Components Modeling (Shunt & Series Converter)/Power Components modeling (Shunt Converter)/dq-axis model of 3-ph RL branch’ is a signal of numeric type complex. However, it is driving a signal of numeric type real
What might be the reason? Please help to resolve the problem upfc, signal mismatch MATLAB Answers — New Questions
Entra ID Allows People to Update their User Principal Names
No Good Reason Why Users Can Update User Principal Names
It’s unclear if Microsoft has updated the default permissions assigned to Entra user accounts, but it is now possible for unprivileged users to update user principal names through interfaces like the Entra admin center and PowerShell. To be clear, an unprivileged user can update the user principal name for their Entra ID account and not for other accounts. Nevertheless, I can’t think of a good reason why any organization would want to allow people to update something fundamental like a user principal name, but they can.
To test the theory, I created a new account for Eric Hammon and attempted to sign into the Entra admin center. I then navigated to the Users section to access the account properties. As you can see from Figure 1, the user principal name is editable.
I went ahead and updated the account to make the user principal name Eric.B.Hammond@office365itpros.com. For good measure, I uploaded a new user photo. The update proceeded without a problem and the result is shown in Figure 2.
A side effect of updating a user principal name is that the user’s primary SMTP address also changes. This is because of the dual write arrangement between Exchange Online and Entra ID whereby updates to mail-related properties occur in both directories. The update to the user principal name also updates the account’s Mail property, and this ripples through to Exchange Online, meaning that the full set of proxy addresses includes a new primary SMTP address (indicated by SMTP:). The previous primary SMTP address is preserved as a proxy to make sure that Exchange Online can deliver messages addressed to the old primary SMTP address.
Get-Mailbox -identity eric.b.hammond@office365itpros.com | Select-Object -ExpandProperty emailaddresses SIP:eric.b.hammond@office365itpros.com SMTP:Eric.B.Hammond@office365itpros.com smtp:Eric.A.Hammond@office365itpros.com smtp:Eric.Hammond@office365itpros.com
Update User Principal Name with PowerShell
After validating that it is possible for a user to update their user principal name and photo via the Entra admin center, I tried with the Microsoft Graph PowerShell SDK (Figure 3). I expected this to work because much of the Entra admin center is built on top of the Microsoft Graph, especially anything to do with user accounts and groups (you can validate this by running the Graph X-Ray tool).
Essentially, these tests indicate that any tool based on the Microsoft Graph Users API will allow users to update their user principal name. I’m not bothered by the Entra admin center allowing people to update their photo because that facility is available elsewhere, notably in OWA and the new Outlook for Windows.
Blocking Access to the Entra Admin Center
Some control can be exerted for the Entra admin center by setting the option to restrict access to users that hold administrative roles (Figure 4).
This is only a partial block because accounts with relatively unprivileged roles, like Reports Reader, can still access the Entra admin center and update their user principal names. On the other hand, it does block casual access and is therefore a recommended setting to have in place.
Blocking Access to the Microsoft Graph PowerShell SDK
The ability to create an interactive session with the Microsoft Graph PowerShell SDK is governed by controls on the Microsoft Graph Command Line Tools enterprise app. Like other enterprise apps created by third parties for use in multiple Entra ID tenants, the instantiation for the app is a service principal that holds the consented permissions available in Graph SDK sessions. It can also hold a set of users and groups who are allowed to access the app. By default, the list of users assigned to the app is empty, which means that any user can run the Connect-MgGraph cmdlet in a PowerShell session to connect to the Graph.
Obviously, allowing open access to such a powerful capability isn’t a good idea, and tenants should take steps to secure access to the Microsoft Graph Command Line Tools app. With controls in place, anyone who isn’t on the approved list will see an AADSTS50105 error and be blocked from access (Figure 5).
And if you’re blocking access to PowerShell for the Graph SDK, consider doing the same for other Microsoft 365 PowerShellmodules.
No Apparent Justification for People to Update User Principal Names
Microsoft doesn’t make changes without reason, so something must have happened to convince the Entra ID developers to allow users to update user principal names. I can’t think of a convincing reason for such a change, but perhaps the logic will become apparent over time. In the meantime, if you don’t like people being able to change user principal names, consider applying the blocks described above.
Insight like this doesn’t come easily. You’ve got to know the technology and understand how to look behind the scenes. Benefit from the knowledge and experience of the Office 365 for IT Pros team by subscribing to the best eBook covering Office 365 and the wider Microsoft 365 ecosystem.