Category: Matlab
Category Archives: Matlab
Unable to launch local server from MATLAB 2015a
The problem is with MATLAB 2015a.
web(‘www.google.com’) , works fine.
Now I am using a local server to launch a web application, but the webpage is empty, means nothing is loaded.
stat = web(‘localserver’) gives ‘0’ as output argument , means found and started system browser.
com.mathworks.mlwidgets.html.HtmlComponentFactory.setDefaultType(‘HTMLRENDERER’);
com.mathworks.mlwidgets.html.HtmlComponentFactory.setDefaultType(‘HTMLPANEL’);
Switching between these two is not helping as well
Also, the same local server works fine in MATLAB 2021a version.The problem is with MATLAB 2015a.
web(‘www.google.com’) , works fine.
Now I am using a local server to launch a web application, but the webpage is empty, means nothing is loaded.
stat = web(‘localserver’) gives ‘0’ as output argument , means found and started system browser.
com.mathworks.mlwidgets.html.HtmlComponentFactory.setDefaultType(‘HTMLRENDERER’);
com.mathworks.mlwidgets.html.HtmlComponentFactory.setDefaultType(‘HTMLPANEL’);
Switching between these two is not helping as well
Also, the same local server works fine in MATLAB 2021a version. The problem is with MATLAB 2015a.
web(‘www.google.com’) , works fine.
Now I am using a local server to launch a web application, but the webpage is empty, means nothing is loaded.
stat = web(‘localserver’) gives ‘0’ as output argument , means found and started system browser.
com.mathworks.mlwidgets.html.HtmlComponentFactory.setDefaultType(‘HTMLRENDERER’);
com.mathworks.mlwidgets.html.HtmlComponentFactory.setDefaultType(‘HTMLPANEL’);
Switching between these two is not helping as well
Also, the same local server works fine in MATLAB 2021a version. matlab, web, antique version MATLAB Answers — New Questions
Detecting and correcting electrode problems and static noise in an ECG signal
Hello everyone,
I am currently working on ECG signal analysis in MATLAB, and I’m facing some challenges in detecting and correcting electrode problems as well as static noise. I’m seeking advice or techniques to address these specific issues.
Detection of electrode problems:
How can I detect artifacts or electrode problems in an ECG signal? Are there specific detection techniques or algorithms available in MATLAB to identify these issues?
Correction of electrode problems:
Once electrode problems are detected, what are the best approaches to correct or remove them from the ECG signal? Are there effective filtering or preprocessing methods that I can implement in MATLAB?
Static noise reduction:
In addition to electrode problems, I’m also dealing with static noise in my ECG signals. How can I effectively reduce this noise? Are there recommended noise suppression filters or techniques for this task?
Any suggestions, resources, or code examples would be greatly appreciated. Thank you in advance for your assistance!
Best regards,Hello everyone,
I am currently working on ECG signal analysis in MATLAB, and I’m facing some challenges in detecting and correcting electrode problems as well as static noise. I’m seeking advice or techniques to address these specific issues.
Detection of electrode problems:
How can I detect artifacts or electrode problems in an ECG signal? Are there specific detection techniques or algorithms available in MATLAB to identify these issues?
Correction of electrode problems:
Once electrode problems are detected, what are the best approaches to correct or remove them from the ECG signal? Are there effective filtering or preprocessing methods that I can implement in MATLAB?
Static noise reduction:
In addition to electrode problems, I’m also dealing with static noise in my ECG signals. How can I effectively reduce this noise? Are there recommended noise suppression filters or techniques for this task?
Any suggestions, resources, or code examples would be greatly appreciated. Thank you in advance for your assistance!
Best regards, Hello everyone,
I am currently working on ECG signal analysis in MATLAB, and I’m facing some challenges in detecting and correcting electrode problems as well as static noise. I’m seeking advice or techniques to address these specific issues.
Detection of electrode problems:
How can I detect artifacts or electrode problems in an ECG signal? Are there specific detection techniques or algorithms available in MATLAB to identify these issues?
Correction of electrode problems:
Once electrode problems are detected, what are the best approaches to correct or remove them from the ECG signal? Are there effective filtering or preprocessing methods that I can implement in MATLAB?
Static noise reduction:
In addition to electrode problems, I’m also dealing with static noise in my ECG signals. How can I effectively reduce this noise? Are there recommended noise suppression filters or techniques for this task?
Any suggestions, resources, or code examples would be greatly appreciated. Thank you in advance for your assistance!
Best regards, ecg, signal processing, noises, static_noise, electrodes_problems MATLAB Answers — New Questions
Matlab equivalent to Java bigdecimal rounding of Half_up?
Is there a Matlab function that mimics the Half_up rounding in Java bigdecimal? Specifically, when the decimal portion is exactly .5, round is towards positive infinity. Example: 3.5 rounds to 4 and -3.5 rounds to -3. I didn’t see anything like this in the help for round().Is there a Matlab function that mimics the Half_up rounding in Java bigdecimal? Specifically, when the decimal portion is exactly .5, round is towards positive infinity. Example: 3.5 rounds to 4 and -3.5 rounds to -3. I didn’t see anything like this in the help for round(). Is there a Matlab function that mimics the Half_up rounding in Java bigdecimal? Specifically, when the decimal portion is exactly .5, round is towards positive infinity. Example: 3.5 rounds to 4 and -3.5 rounds to -3. I didn’t see anything like this in the help for round(). round half_up MATLAB Answers — New Questions
Assigning a toolbox license to a floating user
I am new to administering Matworks licenses.
What is required to assign a matlab license along with a statistics_toolbox to a user who has not been allocated a license to date.I am new to administering Matworks licenses.
What is required to assign a matlab license along with a statistics_toolbox to a user who has not been allocated a license to date. I am new to administering Matworks licenses.
What is required to assign a matlab license along with a statistics_toolbox to a user who has not been allocated a license to date. license administration. MATLAB Answers — New Questions
How to convert the input bump’s height to force exerted by that bump?
Dear fellows, I am working on mass damper system in simulink. I have modelled the simple mass damper equation i.e. F=MXdd+CXd+KX.
In the given equation "M" is no doubt the mass of the load. Looking at the picture provided, its 100kg.
Now I want to calculate the force i.e. "F", that will be the input to the system. For that I have created a simple sinusoidal form, considering it as the bump input height. But I just cant input the sinusoidal form instead of the force, as it will be considered as force then. I want to convert this bump’s height to Force that will go into the system.
So If I apply F=ma, a could be the double derivative of the height what will be the mass! Is it will be the mass of the load i.e. 100kg or it will be the mass of the damper or something else? (Considering a quater car model)Dear fellows, I am working on mass damper system in simulink. I have modelled the simple mass damper equation i.e. F=MXdd+CXd+KX.
In the given equation "M" is no doubt the mass of the load. Looking at the picture provided, its 100kg.
Now I want to calculate the force i.e. "F", that will be the input to the system. For that I have created a simple sinusoidal form, considering it as the bump input height. But I just cant input the sinusoidal form instead of the force, as it will be considered as force then. I want to convert this bump’s height to Force that will go into the system.
So If I apply F=ma, a could be the double derivative of the height what will be the mass! Is it will be the mass of the load i.e. 100kg or it will be the mass of the damper or something else? (Considering a quater car model) Dear fellows, I am working on mass damper system in simulink. I have modelled the simple mass damper equation i.e. F=MXdd+CXd+KX.
In the given equation "M" is no doubt the mass of the load. Looking at the picture provided, its 100kg.
Now I want to calculate the force i.e. "F", that will be the input to the system. For that I have created a simple sinusoidal form, considering it as the bump input height. But I just cant input the sinusoidal form instead of the force, as it will be considered as force then. I want to convert this bump’s height to Force that will go into the system.
So If I apply F=ma, a could be the double derivative of the height what will be the mass! Is it will be the mass of the load i.e. 100kg or it will be the mass of the damper or something else? (Considering a quater car model) height to force, bump height to bump input force MATLAB Answers — New Questions
Matlab Simulink encryption method
Hello,
I am looking for Simulink block encryption methods, but the method must be MATLAB version independent. For example, if I encrypt a block in 2018, it should work in 2020 or 2024, regardless of MATLAB version.Hello,
I am looking for Simulink block encryption methods, but the method must be MATLAB version independent. For example, if I encrypt a block in 2018, it should work in 2020 or 2024, regardless of MATLAB version. Hello,
I am looking for Simulink block encryption methods, but the method must be MATLAB version independent. For example, if I encrypt a block in 2018, it should work in 2020 or 2024, regardless of MATLAB version. matlab, cryptage, aes, protected model, simulink.protectedmodel.createharness MATLAB Answers — New Questions
MATLAB GPU UBUNTU 20.04 compatibility CUDA driver
Dear community,
I have an issue with CUDA toolkit versions and driver.
I installed proprietary software form NVIDIA with version 12.5 of cuda toolkit and 550 of driver. This shows eveything is correct from nvidia. ‘nvidia-smi’ and ‘nvcc –version’ works fine.
The issue is when opening any version of MATLAB 2024a, 2023a, 2022a, it doesn’t show any GPU available.
Then I tried with installing 12 cuda toolkit and 525 driver but there seem’s to be an issue when installing the driver. The cuda toolkit install smoothly.
Do you recommend any version mixture compatible?
Thank you for all the help in advance.Dear community,
I have an issue with CUDA toolkit versions and driver.
I installed proprietary software form NVIDIA with version 12.5 of cuda toolkit and 550 of driver. This shows eveything is correct from nvidia. ‘nvidia-smi’ and ‘nvcc –version’ works fine.
The issue is when opening any version of MATLAB 2024a, 2023a, 2022a, it doesn’t show any GPU available.
Then I tried with installing 12 cuda toolkit and 525 driver but there seem’s to be an issue when installing the driver. The cuda toolkit install smoothly.
Do you recommend any version mixture compatible?
Thank you for all the help in advance. Dear community,
I have an issue with CUDA toolkit versions and driver.
I installed proprietary software form NVIDIA with version 12.5 of cuda toolkit and 550 of driver. This shows eveything is correct from nvidia. ‘nvidia-smi’ and ‘nvcc –version’ works fine.
The issue is when opening any version of MATLAB 2024a, 2023a, 2022a, it doesn’t show any GPU available.
Then I tried with installing 12 cuda toolkit and 525 driver but there seem’s to be an issue when installing the driver. The cuda toolkit install smoothly.
Do you recommend any version mixture compatible?
Thank you for all the help in advance. gpu, ubuntu20.04, matlab2024a, matlab2023a, matlab2022a, cuda12.5, cuda12.0, driver550, driver525 MATLAB Answers — New Questions
problem with the intensity in *.spc file tgspcread
I am using the tgspcread function to import *.spc files from a spectrometer.
The function reads everything fine, however the intensity of the spectra is much lower than it should be.
When I compare the intensity using the spectrometer program there is a difference of several orders of magnitude in the intensities and completely arbitrary. It appears that the tgspcread function is dividing the intensity of each spectrum by an arbitrary factor.
Does anyone have any idea what the function is doing?
below an exampleI am using the tgspcread function to import *.spc files from a spectrometer.
The function reads everything fine, however the intensity of the spectra is much lower than it should be.
When I compare the intensity using the spectrometer program there is a difference of several orders of magnitude in the intensities and completely arbitrary. It appears that the tgspcread function is dividing the intensity of each spectrum by an arbitrary factor.
Does anyone have any idea what the function is doing?
below an example I am using the tgspcread function to import *.spc files from a spectrometer.
The function reads everything fine, however the intensity of the spectra is much lower than it should be.
When I compare the intensity using the spectrometer program there is a difference of several orders of magnitude in the intensities and completely arbitrary. It appears that the tgspcread function is dividing the intensity of each spectrum by an arbitrary factor.
Does anyone have any idea what the function is doing?
below an example *.spc files, tgspcread MATLAB Answers — New Questions
Cannot find Preferences > Keyboard > Shortcuts after enabling dark mode
I am in trouble changing the keypoard shortcut preferences after enabling the dark mode in MATLAB R2023b.
I followed the procedures desribed in Try Dark Mode on Desktop MATLAB with the ‘New Desktop for MATLAB’ beta » The MATLAB Blog – MATLAB & Simulink (mathworks.com) to enable the dark mode. However, after this change, I cannot open the Keyboard Shortcuts Preferences page. According to Customize Keyboard Shortcuts – MATLAB & Simulink (mathworks.com), it can be opened by going to Home tab, clicking Preferences, then selecting MATLAB > Keyboard > Shortcuts, but I only see "Delimeter Matching" preferences and don’t see "Shortcuts" preference. Does anyone have a similar issue?I am in trouble changing the keypoard shortcut preferences after enabling the dark mode in MATLAB R2023b.
I followed the procedures desribed in Try Dark Mode on Desktop MATLAB with the ‘New Desktop for MATLAB’ beta » The MATLAB Blog – MATLAB & Simulink (mathworks.com) to enable the dark mode. However, after this change, I cannot open the Keyboard Shortcuts Preferences page. According to Customize Keyboard Shortcuts – MATLAB & Simulink (mathworks.com), it can be opened by going to Home tab, clicking Preferences, then selecting MATLAB > Keyboard > Shortcuts, but I only see "Delimeter Matching" preferences and don’t see "Shortcuts" preference. Does anyone have a similar issue? I am in trouble changing the keypoard shortcut preferences after enabling the dark mode in MATLAB R2023b.
I followed the procedures desribed in Try Dark Mode on Desktop MATLAB with the ‘New Desktop for MATLAB’ beta » The MATLAB Blog – MATLAB & Simulink (mathworks.com) to enable the dark mode. However, after this change, I cannot open the Keyboard Shortcuts Preferences page. According to Customize Keyboard Shortcuts – MATLAB & Simulink (mathworks.com), it can be opened by going to Home tab, clicking Preferences, then selecting MATLAB > Keyboard > Shortcuts, but I only see "Delimeter Matching" preferences and don’t see "Shortcuts" preference. Does anyone have a similar issue? keyboard shortcuts MATLAB Answers — New Questions
how to get the name of current running m script
hello, how can i get the name of the script that is running at the moment, thanks.hello, how can i get the name of the script that is running at the moment, thanks. hello, how can i get the name of the script that is running at the moment, thanks. script, name MATLAB Answers — New Questions
Rainflow Algorithm needs 3 samples
Hi,
I want to use the build-in rainflow(x,fs) algorithm to calculate the cycles a battery model has run by using it on the State of Charge (&) of the cell. When I try to use the algorithm on the SoC (see picture) I get the following error:
Input time series must have at least 3 samples.
But I set a sample rate fs and as you can see in the picture there is also enough data.
Anyone knows why?Hi,
I want to use the build-in rainflow(x,fs) algorithm to calculate the cycles a battery model has run by using it on the State of Charge (&) of the cell. When I try to use the algorithm on the SoC (see picture) I get the following error:
Input time series must have at least 3 samples.
But I set a sample rate fs and as you can see in the picture there is also enough data.
Anyone knows why? Hi,
I want to use the build-in rainflow(x,fs) algorithm to calculate the cycles a battery model has run by using it on the State of Charge (&) of the cell. When I try to use the algorithm on the SoC (see picture) I get the following error:
Input time series must have at least 3 samples.
But I set a sample rate fs and as you can see in the picture there is also enough data.
Anyone knows why? rainflow, battery MATLAB Answers — New Questions
Monitor and Tune PX4 Host Target Flight Controller with Simulink-Based Plant Model: Mismatched TCP Node
Hi, I’m following the Tutorial here and I’m getting stuck at the last step where the two MATLAB instances are failing to communicate with each other presumably due to mismatched TCP ports. I can’t determine where I may be able to set what ports to sned/receive from.
The following is the Simulink diagnostics output for the first MATLAB instance where I am running PX4Demo_FlightController_top
Updating Model Reference Code Generation Targets
### Starting serial model reference code generation build.
Building FlightController
### Checking status of model reference code generation target for model ‘FlightController’ used in ‘px4Demo_FlightController_top’.
### Model reference code generation target (FlightController.cpp) for model FlightController must be recompiled because FlightController.cpp changed since last build, or it was not compiled.
### Starting build procedure for: FlightController
### Generating code and artifacts to ‘Model specific’ folder structure
### Code for the model reference code generation target for model FlightController is up to date because no functional changes were found in referenced model.
Removing old px4_simulink_app directory: /home/USERNAME/Documents/PX4_Source/Firmware/src/modules/px4_simulink_app.
### Successful completion of build procedure for: FlightController
### Model reference code generation target for FlightController is up to date.
Top Model Build
### Starting build procedure for: px4Demo_FlightController_top
### Generating code and artifacts to ‘Model specific’ folder structure
### Generating code into build folder: /home/USERNAME/MATLAB/Projects/examples/Px4DemoHostTargetWithSimulinkPlant6/work/code/px4Demo_FlightController_top_ert_rtw
Warning: The Simulink model contains a PX4 PWM Output block and the algorithm to be designed is set as "Design Path Follower in Simulink".
The PWM block output might conflict with the PWM values generated by the default PX4 Controllers in this case.
### Generated code for ‘px4Demo_FlightController_top’ is up to date because no structural, parameter or code replacement library changes were found.
### Saving binary information cache.
Removing old px4_simulink_app directory: /home/USERNAME/Documents/PX4_Source/Firmware/src/modules/px4_simulink_app.
Build path: /home/USERNAME/MATLAB/Projects/examples/Px4DemoHostTargetWithSimulinkPlant6/work/code/px4Demo_FlightController_top_ert_rtw
### Successful completion of build procedure for: px4Demo_FlightController_top
Build process completed successfully
Build Summary
0 of 2 models built (2 models already up to date)
Build duration: 0h 0m 18.507s
action: EXT_INIT
Creating Target Handler (XCP on TCP/IP)…
Build directory: /home/USERNAME/MATLAB/Projects/examples/Px4DemoHostTargetWithSimulinkPlant6/work/code/px4Demo_FlightController_top_ert_rtw
Target name: 127.0.0.1
Target port: 17725
Warning: The Simulink model contains a PX4 PWM Output block and the algorithm to be designed is set as "Design Path Follower in Simulink".
The PWM block output might conflict with the PWM values generated by the default PX4 Controllers in this case.
### Starting serial model reference code generation build.
### Checking status of model reference code generation target for model ‘FlightController’ used in ‘px4Demo_FlightController_top’.
### Model reference code generation target (FlightController.cpp) for model FlightController must be recompiled because FlightController.cpp changed since last build, or it was not compiled.
### Starting build procedure for: FlightController
### Generating code and artifacts to ‘Model specific’ folder structure
### Checking the status of code in build folder: /home/USERNAME/MATLAB/Projects/examples/Px4DemoHostTargetWithSimulinkPlant6/work/code/slprj/ert/FlightController
### Code for the model reference code generation target for model FlightController is up to date because no functional changes were found in referenced model.
Removing old px4_simulink_app directory: /home/USERNAME/Documents/PX4_Source/Firmware/src/modules/px4_simulink_app.
### Successful completion of build procedure for: FlightController
### Model reference code generation target for FlightController is up to date.
Build Summary
0 of 1 models built (1 models already up to date)
Build duration: 0h 0m 3.612s
For referenced models, external mode simulations do not support the following:
The use of blocks to view signals from the target application.
Tuning or uploading of model parameters.
Component:Simulink | Category:Model warning
action: EXT_CONNECT
Connecting to the target…
External Mode Open Protocol Connect command failed
Caused by:
Could not connect to target application: XCP TCP/IP error: Connect failed
Component:Simulink | Category:Block diagram error
Unable to connect to the ‘PX4 Host Target’ target for ‘px4Demo_FlightController_top’.
As you might be able to tell, the code generation and compilation works just fine and I get the popup window saying that "the monitor and tune build is complete". The problematic bit I want to highlight is "Target port: 17725", which is in contrast with the port 4560 specified in Quad_Plant_top.slx. Here is the Simulink Diagnostics output from the Second MATLAB instance where I am running Quad_Plant_top:
An error occurred while running the simulation and the simulation was terminated
Caused by:
MATLAB System block ‘Quad_Plant_top/MATLAB System1’ error occurred when invoking ‘stepImpl’ method of ‘px4HostTarget_TCPIP_Write’. The error was thrown from ‘
‘/home/USERNAME/Documents/MATLAB/SupportPackages/R2022b/toolbox/target/supportpackages/px4/px4examples/exampleTCPFiles/px4HostTarget_TCPIP_Write.m’ at line 42′.
Failed to write from the server. A TCP/IP client must be connected to the server.
Am I just timing things wrong when starting one and resuming (hitting "ok") on the other? Or is there perhaps some setup step I may have forgotten? I could use some guidance.
I am on Ubuntu 18.04.6, using MATLAB/Simulink 2022b, and PX4 firmware v1.12.3.Hi, I’m following the Tutorial here and I’m getting stuck at the last step where the two MATLAB instances are failing to communicate with each other presumably due to mismatched TCP ports. I can’t determine where I may be able to set what ports to sned/receive from.
The following is the Simulink diagnostics output for the first MATLAB instance where I am running PX4Demo_FlightController_top
Updating Model Reference Code Generation Targets
### Starting serial model reference code generation build.
Building FlightController
### Checking status of model reference code generation target for model ‘FlightController’ used in ‘px4Demo_FlightController_top’.
### Model reference code generation target (FlightController.cpp) for model FlightController must be recompiled because FlightController.cpp changed since last build, or it was not compiled.
### Starting build procedure for: FlightController
### Generating code and artifacts to ‘Model specific’ folder structure
### Code for the model reference code generation target for model FlightController is up to date because no functional changes were found in referenced model.
Removing old px4_simulink_app directory: /home/USERNAME/Documents/PX4_Source/Firmware/src/modules/px4_simulink_app.
### Successful completion of build procedure for: FlightController
### Model reference code generation target for FlightController is up to date.
Top Model Build
### Starting build procedure for: px4Demo_FlightController_top
### Generating code and artifacts to ‘Model specific’ folder structure
### Generating code into build folder: /home/USERNAME/MATLAB/Projects/examples/Px4DemoHostTargetWithSimulinkPlant6/work/code/px4Demo_FlightController_top_ert_rtw
Warning: The Simulink model contains a PX4 PWM Output block and the algorithm to be designed is set as "Design Path Follower in Simulink".
The PWM block output might conflict with the PWM values generated by the default PX4 Controllers in this case.
### Generated code for ‘px4Demo_FlightController_top’ is up to date because no structural, parameter or code replacement library changes were found.
### Saving binary information cache.
Removing old px4_simulink_app directory: /home/USERNAME/Documents/PX4_Source/Firmware/src/modules/px4_simulink_app.
Build path: /home/USERNAME/MATLAB/Projects/examples/Px4DemoHostTargetWithSimulinkPlant6/work/code/px4Demo_FlightController_top_ert_rtw
### Successful completion of build procedure for: px4Demo_FlightController_top
Build process completed successfully
Build Summary
0 of 2 models built (2 models already up to date)
Build duration: 0h 0m 18.507s
action: EXT_INIT
Creating Target Handler (XCP on TCP/IP)…
Build directory: /home/USERNAME/MATLAB/Projects/examples/Px4DemoHostTargetWithSimulinkPlant6/work/code/px4Demo_FlightController_top_ert_rtw
Target name: 127.0.0.1
Target port: 17725
Warning: The Simulink model contains a PX4 PWM Output block and the algorithm to be designed is set as "Design Path Follower in Simulink".
The PWM block output might conflict with the PWM values generated by the default PX4 Controllers in this case.
### Starting serial model reference code generation build.
### Checking status of model reference code generation target for model ‘FlightController’ used in ‘px4Demo_FlightController_top’.
### Model reference code generation target (FlightController.cpp) for model FlightController must be recompiled because FlightController.cpp changed since last build, or it was not compiled.
### Starting build procedure for: FlightController
### Generating code and artifacts to ‘Model specific’ folder structure
### Checking the status of code in build folder: /home/USERNAME/MATLAB/Projects/examples/Px4DemoHostTargetWithSimulinkPlant6/work/code/slprj/ert/FlightController
### Code for the model reference code generation target for model FlightController is up to date because no functional changes were found in referenced model.
Removing old px4_simulink_app directory: /home/USERNAME/Documents/PX4_Source/Firmware/src/modules/px4_simulink_app.
### Successful completion of build procedure for: FlightController
### Model reference code generation target for FlightController is up to date.
Build Summary
0 of 1 models built (1 models already up to date)
Build duration: 0h 0m 3.612s
For referenced models, external mode simulations do not support the following:
The use of blocks to view signals from the target application.
Tuning or uploading of model parameters.
Component:Simulink | Category:Model warning
action: EXT_CONNECT
Connecting to the target…
External Mode Open Protocol Connect command failed
Caused by:
Could not connect to target application: XCP TCP/IP error: Connect failed
Component:Simulink | Category:Block diagram error
Unable to connect to the ‘PX4 Host Target’ target for ‘px4Demo_FlightController_top’.
As you might be able to tell, the code generation and compilation works just fine and I get the popup window saying that "the monitor and tune build is complete". The problematic bit I want to highlight is "Target port: 17725", which is in contrast with the port 4560 specified in Quad_Plant_top.slx. Here is the Simulink Diagnostics output from the Second MATLAB instance where I am running Quad_Plant_top:
An error occurred while running the simulation and the simulation was terminated
Caused by:
MATLAB System block ‘Quad_Plant_top/MATLAB System1’ error occurred when invoking ‘stepImpl’ method of ‘px4HostTarget_TCPIP_Write’. The error was thrown from ‘
‘/home/USERNAME/Documents/MATLAB/SupportPackages/R2022b/toolbox/target/supportpackages/px4/px4examples/exampleTCPFiles/px4HostTarget_TCPIP_Write.m’ at line 42′.
Failed to write from the server. A TCP/IP client must be connected to the server.
Am I just timing things wrong when starting one and resuming (hitting "ok") on the other? Or is there perhaps some setup step I may have forgotten? I could use some guidance.
I am on Ubuntu 18.04.6, using MATLAB/Simulink 2022b, and PX4 firmware v1.12.3. Hi, I’m following the Tutorial here and I’m getting stuck at the last step where the two MATLAB instances are failing to communicate with each other presumably due to mismatched TCP ports. I can’t determine where I may be able to set what ports to sned/receive from.
The following is the Simulink diagnostics output for the first MATLAB instance where I am running PX4Demo_FlightController_top
Updating Model Reference Code Generation Targets
### Starting serial model reference code generation build.
Building FlightController
### Checking status of model reference code generation target for model ‘FlightController’ used in ‘px4Demo_FlightController_top’.
### Model reference code generation target (FlightController.cpp) for model FlightController must be recompiled because FlightController.cpp changed since last build, or it was not compiled.
### Starting build procedure for: FlightController
### Generating code and artifacts to ‘Model specific’ folder structure
### Code for the model reference code generation target for model FlightController is up to date because no functional changes were found in referenced model.
Removing old px4_simulink_app directory: /home/USERNAME/Documents/PX4_Source/Firmware/src/modules/px4_simulink_app.
### Successful completion of build procedure for: FlightController
### Model reference code generation target for FlightController is up to date.
Top Model Build
### Starting build procedure for: px4Demo_FlightController_top
### Generating code and artifacts to ‘Model specific’ folder structure
### Generating code into build folder: /home/USERNAME/MATLAB/Projects/examples/Px4DemoHostTargetWithSimulinkPlant6/work/code/px4Demo_FlightController_top_ert_rtw
Warning: The Simulink model contains a PX4 PWM Output block and the algorithm to be designed is set as "Design Path Follower in Simulink".
The PWM block output might conflict with the PWM values generated by the default PX4 Controllers in this case.
### Generated code for ‘px4Demo_FlightController_top’ is up to date because no structural, parameter or code replacement library changes were found.
### Saving binary information cache.
Removing old px4_simulink_app directory: /home/USERNAME/Documents/PX4_Source/Firmware/src/modules/px4_simulink_app.
Build path: /home/USERNAME/MATLAB/Projects/examples/Px4DemoHostTargetWithSimulinkPlant6/work/code/px4Demo_FlightController_top_ert_rtw
### Successful completion of build procedure for: px4Demo_FlightController_top
Build process completed successfully
Build Summary
0 of 2 models built (2 models already up to date)
Build duration: 0h 0m 18.507s
action: EXT_INIT
Creating Target Handler (XCP on TCP/IP)…
Build directory: /home/USERNAME/MATLAB/Projects/examples/Px4DemoHostTargetWithSimulinkPlant6/work/code/px4Demo_FlightController_top_ert_rtw
Target name: 127.0.0.1
Target port: 17725
Warning: The Simulink model contains a PX4 PWM Output block and the algorithm to be designed is set as "Design Path Follower in Simulink".
The PWM block output might conflict with the PWM values generated by the default PX4 Controllers in this case.
### Starting serial model reference code generation build.
### Checking status of model reference code generation target for model ‘FlightController’ used in ‘px4Demo_FlightController_top’.
### Model reference code generation target (FlightController.cpp) for model FlightController must be recompiled because FlightController.cpp changed since last build, or it was not compiled.
### Starting build procedure for: FlightController
### Generating code and artifacts to ‘Model specific’ folder structure
### Checking the status of code in build folder: /home/USERNAME/MATLAB/Projects/examples/Px4DemoHostTargetWithSimulinkPlant6/work/code/slprj/ert/FlightController
### Code for the model reference code generation target for model FlightController is up to date because no functional changes were found in referenced model.
Removing old px4_simulink_app directory: /home/USERNAME/Documents/PX4_Source/Firmware/src/modules/px4_simulink_app.
### Successful completion of build procedure for: FlightController
### Model reference code generation target for FlightController is up to date.
Build Summary
0 of 1 models built (1 models already up to date)
Build duration: 0h 0m 3.612s
For referenced models, external mode simulations do not support the following:
The use of blocks to view signals from the target application.
Tuning or uploading of model parameters.
Component:Simulink | Category:Model warning
action: EXT_CONNECT
Connecting to the target…
External Mode Open Protocol Connect command failed
Caused by:
Could not connect to target application: XCP TCP/IP error: Connect failed
Component:Simulink | Category:Block diagram error
Unable to connect to the ‘PX4 Host Target’ target for ‘px4Demo_FlightController_top’.
As you might be able to tell, the code generation and compilation works just fine and I get the popup window saying that "the monitor and tune build is complete". The problematic bit I want to highlight is "Target port: 17725", which is in contrast with the port 4560 specified in Quad_Plant_top.slx. Here is the Simulink Diagnostics output from the Second MATLAB instance where I am running Quad_Plant_top:
An error occurred while running the simulation and the simulation was terminated
Caused by:
MATLAB System block ‘Quad_Plant_top/MATLAB System1’ error occurred when invoking ‘stepImpl’ method of ‘px4HostTarget_TCPIP_Write’. The error was thrown from ‘
‘/home/USERNAME/Documents/MATLAB/SupportPackages/R2022b/toolbox/target/supportpackages/px4/px4examples/exampleTCPFiles/px4HostTarget_TCPIP_Write.m’ at line 42′.
Failed to write from the server. A TCP/IP client must be connected to the server.
Am I just timing things wrong when starting one and resuming (hitting "ok") on the other? Or is there perhaps some setup step I may have forgotten? I could use some guidance.
I am on Ubuntu 18.04.6, using MATLAB/Simulink 2022b, and PX4 firmware v1.12.3. px4 MATLAB Answers — New Questions
Use sfit object for multiobjective optimization
Hello everybody,
I want to solve an optimization problem regarding 3 objectives and 2 variables. The data that needs to be optimized may differ dependant on the users input.
My approach was to first generate arrays or vectors that hold the in- and output data. I can now generate 3 surface fit (sfit) objects for every objective that needs to be optimized. The gamultibj algorithm now suggests that I use these functions to create a fitness function, which then will be optimized. However I dont understand how I can create a useable fitness function out of the previously generated sfit objects. To me it seems the gamultiobj algorithm only wirks with a "hard coded" fitness function.
Relevant Code:
% v_n_ges / v_n_P holds all variables
% v_EW / v_T_med and v_K_med holds all objectives
% generate functions to optimize
EW_fit = fit([v_n_ges, v_n_P], v_EW, ‘poly22’);
T_med_fit = fit([v_n_ges, v_n_P], v_T_med, ‘poly22’);
K_med_fit = fit([v_n_ges, v_n_P], v_K_med, ‘poly22’);
% Multiobjective Optimization via fitness function
fitnessfcn = @Fitnessfcn;
numberOfVariables = 3;
[x, fval] = gamultiobj(fitnessfcn, numberOfVariables);
%% Generate fitness function (in progress)
function f = Fitnessfcn (x) % The fitness function would need an input row vector size 2 containing n_ges and n_P
% but also the sfit objects
% Allocate output
f = zeros(1,3);
f(1) = @EW_fit;
f(2) = @T_med_fit;
f(3) = @K_med_fit;
end
Also I was wondering if there is any way to skip the "sfit-step" and just directly work with the vectors/arrays.
Thanks in advance for your support and with best regardsHello everybody,
I want to solve an optimization problem regarding 3 objectives and 2 variables. The data that needs to be optimized may differ dependant on the users input.
My approach was to first generate arrays or vectors that hold the in- and output data. I can now generate 3 surface fit (sfit) objects for every objective that needs to be optimized. The gamultibj algorithm now suggests that I use these functions to create a fitness function, which then will be optimized. However I dont understand how I can create a useable fitness function out of the previously generated sfit objects. To me it seems the gamultiobj algorithm only wirks with a "hard coded" fitness function.
Relevant Code:
% v_n_ges / v_n_P holds all variables
% v_EW / v_T_med and v_K_med holds all objectives
% generate functions to optimize
EW_fit = fit([v_n_ges, v_n_P], v_EW, ‘poly22’);
T_med_fit = fit([v_n_ges, v_n_P], v_T_med, ‘poly22’);
K_med_fit = fit([v_n_ges, v_n_P], v_K_med, ‘poly22’);
% Multiobjective Optimization via fitness function
fitnessfcn = @Fitnessfcn;
numberOfVariables = 3;
[x, fval] = gamultiobj(fitnessfcn, numberOfVariables);
%% Generate fitness function (in progress)
function f = Fitnessfcn (x) % The fitness function would need an input row vector size 2 containing n_ges and n_P
% but also the sfit objects
% Allocate output
f = zeros(1,3);
f(1) = @EW_fit;
f(2) = @T_med_fit;
f(3) = @K_med_fit;
end
Also I was wondering if there is any way to skip the "sfit-step" and just directly work with the vectors/arrays.
Thanks in advance for your support and with best regards Hello everybody,
I want to solve an optimization problem regarding 3 objectives and 2 variables. The data that needs to be optimized may differ dependant on the users input.
My approach was to first generate arrays or vectors that hold the in- and output data. I can now generate 3 surface fit (sfit) objects for every objective that needs to be optimized. The gamultibj algorithm now suggests that I use these functions to create a fitness function, which then will be optimized. However I dont understand how I can create a useable fitness function out of the previously generated sfit objects. To me it seems the gamultiobj algorithm only wirks with a "hard coded" fitness function.
Relevant Code:
% v_n_ges / v_n_P holds all variables
% v_EW / v_T_med and v_K_med holds all objectives
% generate functions to optimize
EW_fit = fit([v_n_ges, v_n_P], v_EW, ‘poly22’);
T_med_fit = fit([v_n_ges, v_n_P], v_T_med, ‘poly22’);
K_med_fit = fit([v_n_ges, v_n_P], v_K_med, ‘poly22’);
% Multiobjective Optimization via fitness function
fitnessfcn = @Fitnessfcn;
numberOfVariables = 3;
[x, fval] = gamultiobj(fitnessfcn, numberOfVariables);
%% Generate fitness function (in progress)
function f = Fitnessfcn (x) % The fitness function would need an input row vector size 2 containing n_ges and n_P
% but also the sfit objects
% Allocate output
f = zeros(1,3);
f(1) = @EW_fit;
f(2) = @T_med_fit;
f(3) = @K_med_fit;
end
Also I was wondering if there is any way to skip the "sfit-step" and just directly work with the vectors/arrays.
Thanks in advance for your support and with best regards sfit, gamultiobj, multiobjective optimization MATLAB Answers — New Questions
The filtfilt function is different in different versions
When I used filtfilt in version R2019b, I had to use input data in double format, but in version R2024, functions can recognize data in single format.But when I increased the order of the filter from second to third order, it became clear that the single format version produced the wrong result, and the result using the double version is still right.
I want to know why, please help me.When I used filtfilt in version R2019b, I had to use input data in double format, but in version R2024, functions can recognize data in single format.But when I increased the order of the filter from second to third order, it became clear that the single format version produced the wrong result, and the result using the double version is still right.
I want to know why, please help me. When I used filtfilt in version R2019b, I had to use input data in double format, but in version R2024, functions can recognize data in single format.But when I increased the order of the filter from second to third order, it became clear that the single format version produced the wrong result, and the result using the double version is still right.
I want to know why, please help me. filtfilt, matlab, lowpass MATLAB Answers — New Questions
How can I solve this error message? ” The generated code exceeds the available memory on the processor. It uses 12.1% of available program memory and 186.6% of available Data memory.”
We are doing the simulink with arduino and chage the fft.
Our simulink cording is this photo.
But When we start Simulink We can’t solve this error message "
The generated code exceeds the available memory on the processor. It uses 12.1% of available program memory and 186.6% of available Data memory."
Please…We are doing the simulink with arduino and chage the fft.
Our simulink cording is this photo.
But When we start Simulink We can’t solve this error message "
The generated code exceeds the available memory on the processor. It uses 12.1% of available program memory and 186.6% of available Data memory."
Please… We are doing the simulink with arduino and chage the fft.
Our simulink cording is this photo.
But When we start Simulink We can’t solve this error message "
The generated code exceeds the available memory on the processor. It uses 12.1% of available program memory and 186.6% of available Data memory."
Please… fft MATLAB Answers — New Questions
create a 3D average curve from two 3D curves
I have curves M1 and M2 composed of x nodes in space.
Is it possible to create an average curve (up to a specific height, from bottom to top – red curve) as in the figure?
load M1_and_M2.mat
figure
plot3(M1(:,1),M1(:,2),M1(:,3),’mo’,’Markersize’,4);
hold on
plot3(M2(:,1),M2(:,2),M2(:,3),’go’,’Markersize’,4);
hold off
axis equal
xlabel(‘x’)
ylabel(‘y’)
zlabel(‘z’)
grid offI have curves M1 and M2 composed of x nodes in space.
Is it possible to create an average curve (up to a specific height, from bottom to top – red curve) as in the figure?
load M1_and_M2.mat
figure
plot3(M1(:,1),M1(:,2),M1(:,3),’mo’,’Markersize’,4);
hold on
plot3(M2(:,1),M2(:,2),M2(:,3),’go’,’Markersize’,4);
hold off
axis equal
xlabel(‘x’)
ylabel(‘y’)
zlabel(‘z’)
grid off I have curves M1 and M2 composed of x nodes in space.
Is it possible to create an average curve (up to a specific height, from bottom to top – red curve) as in the figure?
load M1_and_M2.mat
figure
plot3(M1(:,1),M1(:,2),M1(:,3),’mo’,’Markersize’,4);
hold on
plot3(M2(:,1),M2(:,2),M2(:,3),’go’,’Markersize’,4);
hold off
axis equal
xlabel(‘x’)
ylabel(‘y’)
zlabel(‘z’)
grid off curve, nodes, average, mean, 3d plots, 3d, interpolation, interp MATLAB Answers — New Questions
Why does my Frequency Division Multiplexer demultiplex to negative and not the message signal?
Hi,
I’m working on a project that involves on the practice of communication techniques, designed in simulink. I’m trying to design a Frequency Divison Multiplexer that multiplex 3 modulated signals (AM modulated signals), then demultiplex to obtain the original signals back. However, when designing the demodulation circuit to remove the carrier signal, I’m not sure why its giving a negative amplitude and not the orginal message signals.
I’m confused if its my demodulation circuit or its just the characeristic of an Frequency Divison Multiplexer.
Note: From the multiplexer and modulation, there aren’t any issues as its responding with the correct waveform of modulation and multiplex form.
Perameters:
Input 1 – 1volt, 100Hz message, 3kHz carrier, Sine
input 2 – 1volt, 150Hz message, 2.5Khz Carrier, Sine
input 3 – 1volt, 50Hz message, 1.2Khz Carrier, Sine
Saturation (for all) – 0 lower limit, 3 upper limit
Filter Desginer1 – Butterworth, Lowpass, filter order 3, pass band 3kHz
Filter Designer2 – Butterworth, Low pass, filter order 3, pass band 2.5kHz
Filter Designer3 – Butterworth, Low pass, filter order 3, pass band 1.2Khz
Constant (for all) = -0.3055
Figure 1: Circuit Diagram of Demultiplexer & Demodulation
Figure 2: Scope from the Demultiplex, saturation then the Low Pass Filter Output from order.
Figure 2: scope output from the demodulation stage of the cirucitHi,
I’m working on a project that involves on the practice of communication techniques, designed in simulink. I’m trying to design a Frequency Divison Multiplexer that multiplex 3 modulated signals (AM modulated signals), then demultiplex to obtain the original signals back. However, when designing the demodulation circuit to remove the carrier signal, I’m not sure why its giving a negative amplitude and not the orginal message signals.
I’m confused if its my demodulation circuit or its just the characeristic of an Frequency Divison Multiplexer.
Note: From the multiplexer and modulation, there aren’t any issues as its responding with the correct waveform of modulation and multiplex form.
Perameters:
Input 1 – 1volt, 100Hz message, 3kHz carrier, Sine
input 2 – 1volt, 150Hz message, 2.5Khz Carrier, Sine
input 3 – 1volt, 50Hz message, 1.2Khz Carrier, Sine
Saturation (for all) – 0 lower limit, 3 upper limit
Filter Desginer1 – Butterworth, Lowpass, filter order 3, pass band 3kHz
Filter Designer2 – Butterworth, Low pass, filter order 3, pass band 2.5kHz
Filter Designer3 – Butterworth, Low pass, filter order 3, pass band 1.2Khz
Constant (for all) = -0.3055
Figure 1: Circuit Diagram of Demultiplexer & Demodulation
Figure 2: Scope from the Demultiplex, saturation then the Low Pass Filter Output from order.
Figure 2: scope output from the demodulation stage of the cirucit Hi,
I’m working on a project that involves on the practice of communication techniques, designed in simulink. I’m trying to design a Frequency Divison Multiplexer that multiplex 3 modulated signals (AM modulated signals), then demultiplex to obtain the original signals back. However, when designing the demodulation circuit to remove the carrier signal, I’m not sure why its giving a negative amplitude and not the orginal message signals.
I’m confused if its my demodulation circuit or its just the characeristic of an Frequency Divison Multiplexer.
Note: From the multiplexer and modulation, there aren’t any issues as its responding with the correct waveform of modulation and multiplex form.
Perameters:
Input 1 – 1volt, 100Hz message, 3kHz carrier, Sine
input 2 – 1volt, 150Hz message, 2.5Khz Carrier, Sine
input 3 – 1volt, 50Hz message, 1.2Khz Carrier, Sine
Saturation (for all) – 0 lower limit, 3 upper limit
Filter Desginer1 – Butterworth, Lowpass, filter order 3, pass band 3kHz
Filter Designer2 – Butterworth, Low pass, filter order 3, pass band 2.5kHz
Filter Designer3 – Butterworth, Low pass, filter order 3, pass band 1.2Khz
Constant (for all) = -0.3055
Figure 1: Circuit Diagram of Demultiplexer & Demodulation
Figure 2: Scope from the Demultiplex, saturation then the Low Pass Filter Output from order.
Figure 2: scope output from the demodulation stage of the cirucit simulink, matlab, communication, filter MATLAB Answers — New Questions
Is it possible to change the Matlab preferences outside the MATLAB?
I would like to change the preferences outside the MATLAB which means that I do not want to open the MATLAB and change the preferences. Is there any way to do so?
I also have additional few questions :
Is it possible to replace the entire ML Preferences file before starting ML?
Where is the ML Preference file located?I would like to change the preferences outside the MATLAB which means that I do not want to open the MATLAB and change the preferences. Is there any way to do so?
I also have additional few questions :
Is it possible to replace the entire ML Preferences file before starting ML?
Where is the ML Preference file located? I would like to change the preferences outside the MATLAB which means that I do not want to open the MATLAB and change the preferences. Is there any way to do so?
I also have additional few questions :
Is it possible to replace the entire ML Preferences file before starting ML?
Where is the ML Preference file located? matlab MATLAB Answers — New Questions
Calculate total heat loss by conduction given temperature and depth profile vectors
Hi all,
I need to solve this problem in Matlab. I have a hot body placed over cold ground, this having a thermal conductivity k = 1.
I need to estimate the total heat loss by conduction into the substratum at each timestep.
For each of these timesteps I have a temperature profile and the associated vertical profile at 1cm intervals (see .mat files attached).
How can I estimate the total heat loss (w/m2) at each time interval (i.e., the heat loss for every profile)?
Any help woud be grately appreciated!Hi all,
I need to solve this problem in Matlab. I have a hot body placed over cold ground, this having a thermal conductivity k = 1.
I need to estimate the total heat loss by conduction into the substratum at each timestep.
For each of these timesteps I have a temperature profile and the associated vertical profile at 1cm intervals (see .mat files attached).
How can I estimate the total heat loss (w/m2) at each time interval (i.e., the heat loss for every profile)?
Any help woud be grately appreciated! Hi all,
I need to solve this problem in Matlab. I have a hot body placed over cold ground, this having a thermal conductivity k = 1.
I need to estimate the total heat loss by conduction into the substratum at each timestep.
For each of these timesteps I have a temperature profile and the associated vertical profile at 1cm intervals (see .mat files attached).
How can I estimate the total heat loss (w/m2) at each time interval (i.e., the heat loss for every profile)?
Any help woud be grately appreciated! heat loss, conduction, matlab MATLAB Answers — New Questions
No image is drawn in plots, Problem with low level Graphics error ?
I get this folowing warning on Matlab terminal –
MATLAB has experienced a low-level graphics error, and may not have drawn correctly.
Read about what you can do to prevent this issue at Resolving Low-Level Graphics Issues then restart MATLAB.
To share details of this issue with MathWorks technical support,
please include this file with your service request.
(I am unable to add file as it is confidential, I can maybe save the data in mat format and just give you the plotting script if you want it).
I have attached a picture of my system configurationI get this folowing warning on Matlab terminal –
MATLAB has experienced a low-level graphics error, and may not have drawn correctly.
Read about what you can do to prevent this issue at Resolving Low-Level Graphics Issues then restart MATLAB.
To share details of this issue with MathWorks technical support,
please include this file with your service request.
(I am unable to add file as it is confidential, I can maybe save the data in mat format and just give you the plotting script if you want it).
I have attached a picture of my system configuration I get this folowing warning on Matlab terminal –
MATLAB has experienced a low-level graphics error, and may not have drawn correctly.
Read about what you can do to prevent this issue at Resolving Low-Level Graphics Issues then restart MATLAB.
To share details of this issue with MathWorks technical support,
please include this file with your service request.
(I am unable to add file as it is confidential, I can maybe save the data in mat format and just give you the plotting script if you want it).
I have attached a picture of my system configuration figure graphics, plot image missing, plotting problems, plot, video MATLAB Answers — New Questions