Month: January 2025
How to force y-axis values not to use scientific notation in axes?
My y-axis ranges from 0.001 to 0.003, it always shows up as 1-3 x 10^-3.
How do I force it show up as 0.001 to 0.003?My y-axis ranges from 0.001 to 0.003, it always shows up as 1-3 x 10^-3.
How do I force it show up as 0.001 to 0.003? My y-axis ranges from 0.001 to 0.003, it always shows up as 1-3 x 10^-3.
How do I force it show up as 0.001 to 0.003? axis notation MATLAB Answers — New Questions
Changing Plot colors while using fitlm
I’m trying to plot 4 different sets of data with a linear regression for each. I used the fitlm command to find hte linear regression. My problem arises with the plot all being the same color for each set of data, blue for the points and red for the regression line. I need them to be different colors for each data set for clarity sake.
data=readmatrix(‘straingage_caldata.csv’);
c1F=data(:,1);
c1V=data(:,2);
c3F=data(:,3);
c3V=data(:,4);
c4F=data(:,5);
c4V=data(:,6);
c5F=data(:,7);
c5V=data(:,8);
c1LR=fitlm(c1F,c1V)
c3LR=fitlm(c3F,c3V)
c4LR=fitlm(c4F,c4V)
c5LR=fitlm(c5F,c5V)
figure
hold on
plot(c1LR,"r");
plot(c3LR);
plot(c4LR);
plot(c5LR);
legend(‘Crane 1′,’Crane 1 Lin Reg’,’Crane 3′,’Crane 3 Lin Reg’,’Crane 4′,’Crane 4 Lin Reg’,’Crane 5′,’Crane 5 Lin Reg’,"Location","SouthEast")
thanksI’m trying to plot 4 different sets of data with a linear regression for each. I used the fitlm command to find hte linear regression. My problem arises with the plot all being the same color for each set of data, blue for the points and red for the regression line. I need them to be different colors for each data set for clarity sake.
data=readmatrix(‘straingage_caldata.csv’);
c1F=data(:,1);
c1V=data(:,2);
c3F=data(:,3);
c3V=data(:,4);
c4F=data(:,5);
c4V=data(:,6);
c5F=data(:,7);
c5V=data(:,8);
c1LR=fitlm(c1F,c1V)
c3LR=fitlm(c3F,c3V)
c4LR=fitlm(c4F,c4V)
c5LR=fitlm(c5F,c5V)
figure
hold on
plot(c1LR,"r");
plot(c3LR);
plot(c4LR);
plot(c5LR);
legend(‘Crane 1′,’Crane 1 Lin Reg’,’Crane 3′,’Crane 3 Lin Reg’,’Crane 4′,’Crane 4 Lin Reg’,’Crane 5′,’Crane 5 Lin Reg’,"Location","SouthEast")
thanks I’m trying to plot 4 different sets of data with a linear regression for each. I used the fitlm command to find hte linear regression. My problem arises with the plot all being the same color for each set of data, blue for the points and red for the regression line. I need them to be different colors for each data set for clarity sake.
data=readmatrix(‘straingage_caldata.csv’);
c1F=data(:,1);
c1V=data(:,2);
c3F=data(:,3);
c3V=data(:,4);
c4F=data(:,5);
c4V=data(:,6);
c5F=data(:,7);
c5V=data(:,8);
c1LR=fitlm(c1F,c1V)
c3LR=fitlm(c3F,c3V)
c4LR=fitlm(c4F,c4V)
c5LR=fitlm(c5F,c5V)
figure
hold on
plot(c1LR,"r");
plot(c3LR);
plot(c4LR);
plot(c5LR);
legend(‘Crane 1′,’Crane 1 Lin Reg’,’Crane 3′,’Crane 3 Lin Reg’,’Crane 4′,’Crane 4 Lin Reg’,’Crane 5′,’Crane 5 Lin Reg’,"Location","SouthEast")
thanks fitlm, plot MATLAB Answers — New Questions
How to disable or delete cameratoolbar context menu
Hello Matlab community!
Does anyone here know how to disable or delete the cameratoolbar context menu while maintaining the programmatic functionality of the cameratoolbar? I am asking because I am building a GUI that has is own custom context menu which gets broken when the cameratoolbar is enabled. This issue has been flaggegd five years ago in this post, but received no attention from MathWorks.
I am currently using Matlab R2024a.
Here is the screenshot of the context menu I am referring to:
Up to this point, I tried retrieving ContextMenu handles from the cameratoolbar, and the parent UIFigure, and deleting them but this did not work. Any helpful advice on this problem would be greatly appreciated.
Thanks!Hello Matlab community!
Does anyone here know how to disable or delete the cameratoolbar context menu while maintaining the programmatic functionality of the cameratoolbar? I am asking because I am building a GUI that has is own custom context menu which gets broken when the cameratoolbar is enabled. This issue has been flaggegd five years ago in this post, but received no attention from MathWorks.
I am currently using Matlab R2024a.
Here is the screenshot of the context menu I am referring to:
Up to this point, I tried retrieving ContextMenu handles from the cameratoolbar, and the parent UIFigure, and deleting them but this did not work. Any helpful advice on this problem would be greatly appreciated.
Thanks! Hello Matlab community!
Does anyone here know how to disable or delete the cameratoolbar context menu while maintaining the programmatic functionality of the cameratoolbar? I am asking because I am building a GUI that has is own custom context menu which gets broken when the cameratoolbar is enabled. This issue has been flaggegd five years ago in this post, but received no attention from MathWorks.
I am currently using Matlab R2024a.
Here is the screenshot of the context menu I am referring to:
Up to this point, I tried retrieving ContextMenu handles from the cameratoolbar, and the parent UIFigure, and deleting them but this did not work. Any helpful advice on this problem would be greatly appreciated.
Thanks! cameratoolbar, contextmenu MATLAB Answers — New Questions
Error with installing OpenCV on Raspberry Pi
Hi!
I am setting up my Raspberry Pi (model 4B) for deep learning deployment. I am following the set up steps of the Support Package for Raspberry Pi. The Pi has been flashed with the image "mathworks_raspbian_DL_R22.2.0.img".
When I tried to install the OpenCV library by executing "./installOpenCVLib", I encountered some errors, as shown in the attached screenshot. Apparently the file "opencv_raspberrypi_10.zip" could not be downloaded, although the 3 packages seems to be succesfully installed. Indeed, when I tried to connect to the link to the Mathworks site on my computer, the link was not accessible.
Can you please suggest any alternative ways to install opencv?
Thank you for your help!Hi!
I am setting up my Raspberry Pi (model 4B) for deep learning deployment. I am following the set up steps of the Support Package for Raspberry Pi. The Pi has been flashed with the image "mathworks_raspbian_DL_R22.2.0.img".
When I tried to install the OpenCV library by executing "./installOpenCVLib", I encountered some errors, as shown in the attached screenshot. Apparently the file "opencv_raspberrypi_10.zip" could not be downloaded, although the 3 packages seems to be succesfully installed. Indeed, when I tried to connect to the link to the Mathworks site on my computer, the link was not accessible.
Can you please suggest any alternative ways to install opencv?
Thank you for your help! Hi!
I am setting up my Raspberry Pi (model 4B) for deep learning deployment. I am following the set up steps of the Support Package for Raspberry Pi. The Pi has been flashed with the image "mathworks_raspbian_DL_R22.2.0.img".
When I tried to install the OpenCV library by executing "./installOpenCVLib", I encountered some errors, as shown in the attached screenshot. Apparently the file "opencv_raspberrypi_10.zip" could not be downloaded, although the 3 packages seems to be succesfully installed. Indeed, when I tried to connect to the link to the Mathworks site on my computer, the link was not accessible.
Can you please suggest any alternative ways to install opencv?
Thank you for your help! opencv, raspberry pi, deep learning MATLAB Answers — New Questions
error in merge NC files using easy_NETCDF codes
I am trying to merge 365 NC files (one year images for soil moisture) and I am using the "Easy_NetCDF-1.51" code for merging files, it works but at the last line when run it shows error like"Unrecognized function or variable ‘FUN_nc_merge’.".
previously it showed another error as "too many margins" and I tried to work with less data than 365 but the error is still stable.
how can I merge the files for one year?
the code I am using is as below:
% input_dir: path for the folder containing the files
input_dir = ‘D:uniRS for thesisESA_CCI_SMv07.1combined2019’;
% filelist
filelist = dir(fullfile(input_dir,’*.nc’));
% output filename
output_fn = ‘Merged_Output.nc’;
% name of the demension to be merged.
merge_dim_name = ‘time’;
% compatibility_mode:
% compatibility_mode = 1: write netCDF in ‘CLOBBER’; Compression would be disabled.
% compatibility_mode = 0: write netCDF in ‘NETCDF4’.
compatibility_mode = 0;
strvcat( filelist(:).name )
FUN_nc_merge( input_dir, filelist, output_fn, merge_dim_name, compatibility_mode )
thanks in advance for your help
edithI am trying to merge 365 NC files (one year images for soil moisture) and I am using the "Easy_NetCDF-1.51" code for merging files, it works but at the last line when run it shows error like"Unrecognized function or variable ‘FUN_nc_merge’.".
previously it showed another error as "too many margins" and I tried to work with less data than 365 but the error is still stable.
how can I merge the files for one year?
the code I am using is as below:
% input_dir: path for the folder containing the files
input_dir = ‘D:uniRS for thesisESA_CCI_SMv07.1combined2019’;
% filelist
filelist = dir(fullfile(input_dir,’*.nc’));
% output filename
output_fn = ‘Merged_Output.nc’;
% name of the demension to be merged.
merge_dim_name = ‘time’;
% compatibility_mode:
% compatibility_mode = 1: write netCDF in ‘CLOBBER’; Compression would be disabled.
% compatibility_mode = 0: write netCDF in ‘NETCDF4’.
compatibility_mode = 0;
strvcat( filelist(:).name )
FUN_nc_merge( input_dir, filelist, output_fn, merge_dim_name, compatibility_mode )
thanks in advance for your help
edith I am trying to merge 365 NC files (one year images for soil moisture) and I am using the "Easy_NetCDF-1.51" code for merging files, it works but at the last line when run it shows error like"Unrecognized function or variable ‘FUN_nc_merge’.".
previously it showed another error as "too many margins" and I tried to work with less data than 365 but the error is still stable.
how can I merge the files for one year?
the code I am using is as below:
% input_dir: path for the folder containing the files
input_dir = ‘D:uniRS for thesisESA_CCI_SMv07.1combined2019’;
% filelist
filelist = dir(fullfile(input_dir,’*.nc’));
% output filename
output_fn = ‘Merged_Output.nc’;
% name of the demension to be merged.
merge_dim_name = ‘time’;
% compatibility_mode:
% compatibility_mode = 1: write netCDF in ‘CLOBBER’; Compression would be disabled.
% compatibility_mode = 0: write netCDF in ‘NETCDF4’.
compatibility_mode = 0;
strvcat( filelist(:).name )
FUN_nc_merge( input_dir, filelist, output_fn, merge_dim_name, compatibility_mode )
thanks in advance for your help
edith nc images, merge nc MATLAB Answers — New Questions
“No module named ‘libmwbuffer'” error when converting to numpy
I am trying to convert an array into numpy, but I keep getting this issue:
Python Error: ModuleNotFoundError: No module named ‘libmwbuffer’
Python function ” might not be able to accept input argument at position 1. The function may require a specific
data type that you can construct from the MATLAB array. For more information, see the documentation for Python
function ” and working with Python arrays.
I checked and I have this pyversion, which is supposed to be compatible with Matlab R2024a. what’s the issue?
version: ‘3.9’
executable: ‘C:Program FilesArcGISProbinPythonenvsarcgispro-py3python.EXE’
library: ‘C:Program FilesArcGISProbinPythonenvsarcgispro-py3python39.dll’
home: ‘C:Program FilesArcGISProbinPythonenvsarcgispro-py3’
isloaded: 1
I tried multiple different versions of numpy save
py.numpy.save(output_filename, data);
or
py.numpy.save(strcat(output_filename, ‘.npy’), py.numpy.array(data));
or
py.numpy.save(strcat(output_filename, ‘.npy’), data);I am trying to convert an array into numpy, but I keep getting this issue:
Python Error: ModuleNotFoundError: No module named ‘libmwbuffer’
Python function ” might not be able to accept input argument at position 1. The function may require a specific
data type that you can construct from the MATLAB array. For more information, see the documentation for Python
function ” and working with Python arrays.
I checked and I have this pyversion, which is supposed to be compatible with Matlab R2024a. what’s the issue?
version: ‘3.9’
executable: ‘C:Program FilesArcGISProbinPythonenvsarcgispro-py3python.EXE’
library: ‘C:Program FilesArcGISProbinPythonenvsarcgispro-py3python39.dll’
home: ‘C:Program FilesArcGISProbinPythonenvsarcgispro-py3’
isloaded: 1
I tried multiple different versions of numpy save
py.numpy.save(output_filename, data);
or
py.numpy.save(strcat(output_filename, ‘.npy’), py.numpy.array(data));
or
py.numpy.save(strcat(output_filename, ‘.npy’), data); I am trying to convert an array into numpy, but I keep getting this issue:
Python Error: ModuleNotFoundError: No module named ‘libmwbuffer’
Python function ” might not be able to accept input argument at position 1. The function may require a specific
data type that you can construct from the MATLAB array. For more information, see the documentation for Python
function ” and working with Python arrays.
I checked and I have this pyversion, which is supposed to be compatible with Matlab R2024a. what’s the issue?
version: ‘3.9’
executable: ‘C:Program FilesArcGISProbinPythonenvsarcgispro-py3python.EXE’
library: ‘C:Program FilesArcGISProbinPythonenvsarcgispro-py3python39.dll’
home: ‘C:Program FilesArcGISProbinPythonenvsarcgispro-py3’
isloaded: 1
I tried multiple different versions of numpy save
py.numpy.save(output_filename, data);
or
py.numpy.save(strcat(output_filename, ‘.npy’), py.numpy.array(data));
or
py.numpy.save(strcat(output_filename, ‘.npy’), data); numpy, python, libmwbuffer MATLAB Answers — New Questions
How to unpack full J1939 messages in Simulink, like CAN Unpack?
I am building an application that will use handwritten C++ code combined with autogenerated code from Simulink. I’m hoping to be able to do all the necessary CAN packing/unpacking within Simulink, but some of my hardware devices use J1939. Is there a way, similar to the CAN pack/unpack blocks, to pack/unpack full J1939 messages? Basically, I’d like the J1939 Receive/Transmit blocks to be able to take an input from external code where I will perform the actual J1939 receive.I am building an application that will use handwritten C++ code combined with autogenerated code from Simulink. I’m hoping to be able to do all the necessary CAN packing/unpacking within Simulink, but some of my hardware devices use J1939. Is there a way, similar to the CAN pack/unpack blocks, to pack/unpack full J1939 messages? Basically, I’d like the J1939 Receive/Transmit blocks to be able to take an input from external code where I will perform the actual J1939 receive. I am building an application that will use handwritten C++ code combined with autogenerated code from Simulink. I’m hoping to be able to do all the necessary CAN packing/unpacking within Simulink, but some of my hardware devices use J1939. Is there a way, similar to the CAN pack/unpack blocks, to pack/unpack full J1939 messages? Basically, I’d like the J1939 Receive/Transmit blocks to be able to take an input from external code where I will perform the actual J1939 receive. j1939, can, simulink, c++ MATLAB Answers — New Questions
Is it possible to have a uiconfirm choose an option after a timeout period?
I am trying to modify my uiconfirm popup to select the ‘DefaultOption’ after some time to avoid having the popup open for a long period of time and holding up code execution.
I have already tried using a timer to select one of the options which didn’t seem to work but maybe I did it wrong.
I can explain what I am trying to do and why in further detail if needed.
Here is a barebones example of what I am trying to modify:
closeHdlg = uiconfirm(MainFigure, "Title",’Program’,’Options’,{‘Retry’,’Disconnect’,’Continue’},’DefaultOption’,’Retry’);
switch closeHdlg
case ‘Retry’
% Hidden for confidentiality
case ‘Disconnect’
% Hidden for confidentiality
case ‘Continue’
% Hidden for confidentiality
case ”
% close box and do nothing
end % end switchI am trying to modify my uiconfirm popup to select the ‘DefaultOption’ after some time to avoid having the popup open for a long period of time and holding up code execution.
I have already tried using a timer to select one of the options which didn’t seem to work but maybe I did it wrong.
I can explain what I am trying to do and why in further detail if needed.
Here is a barebones example of what I am trying to modify:
closeHdlg = uiconfirm(MainFigure, "Title",’Program’,’Options’,{‘Retry’,’Disconnect’,’Continue’},’DefaultOption’,’Retry’);
switch closeHdlg
case ‘Retry’
% Hidden for confidentiality
case ‘Disconnect’
% Hidden for confidentiality
case ‘Continue’
% Hidden for confidentiality
case ”
% close box and do nothing
end % end switch I am trying to modify my uiconfirm popup to select the ‘DefaultOption’ after some time to avoid having the popup open for a long period of time and holding up code execution.
I have already tried using a timer to select one of the options which didn’t seem to work but maybe I did it wrong.
I can explain what I am trying to do and why in further detail if needed.
Here is a barebones example of what I am trying to modify:
closeHdlg = uiconfirm(MainFigure, "Title",’Program’,’Options’,{‘Retry’,’Disconnect’,’Continue’},’DefaultOption’,’Retry’);
switch closeHdlg
case ‘Retry’
% Hidden for confidentiality
case ‘Disconnect’
% Hidden for confidentiality
case ‘Continue’
% Hidden for confidentiality
case ”
% close box and do nothing
end % end switch matlab gui, uiconfirm, timeout MATLAB Answers — New Questions
Multiple Matlab version, DCOM config?
I currently have a machine running Matlab 2018b that I’m connection to using a WCF service to execute code and I see the DCOM config as Matlab.Application 9.5. However when I also installed Matlab 2022b I now also see Matlab.Application 9.13 but the service is still connecting to the 9.5 CLSID. Is there a way to set the 9.13 version as the preference or do I need to uninstall 2018 and thus remove the 9.5?I currently have a machine running Matlab 2018b that I’m connection to using a WCF service to execute code and I see the DCOM config as Matlab.Application 9.5. However when I also installed Matlab 2022b I now also see Matlab.Application 9.13 but the service is still connecting to the 9.5 CLSID. Is there a way to set the 9.13 version as the preference or do I need to uninstall 2018 and thus remove the 9.5? I currently have a machine running Matlab 2018b that I’m connection to using a WCF service to execute code and I see the DCOM config as Matlab.Application 9.5. However when I also installed Matlab 2022b I now also see Matlab.Application 9.13 but the service is still connecting to the 9.5 CLSID. Is there a way to set the 9.13 version as the preference or do I need to uninstall 2018 and thus remove the 9.5? matlab, dcom MATLAB Answers — New Questions
Error on startup : Cannot locate or initialize class com/mathworks/jmi/OpaqueJavaInterface.
I am on Manjaro Linux and I installed Matlab R2024b.
When trying to start Matlab, I get the following error :
Cannot locate or initialize class com/mathworks/jmi/OpaqueJavaInterface.
java.lang.NoClassDefFoundError: com/mathworks/jmi/OpaqueJavaInterface
Caused by: java.lang.ClassNotFoundException: com.mathworks.jmi.OpaqueJavaInterface
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
I tried changing the java version used by using matlab_jenv to switch to the default version on my machine, 1.7. It did not make a difference. Command:
sudo ./matlab_jenv -allusers system 1 ✘
Result: 1 ✘
JavaEnvironment with properties
Version : openjdk version "17.0.13" 2024-10-15
OpenJDK Runtime Environment (build 17.0.13+11)
OpenJDK 64-Bit Server VM (build 17.0.13+11, mixed mode, sharing)
Home : /usr/lib/jvm/java-17-openjdk
Library : /usr/lib/jvm/java-17-openjdk/lib/server/libjvm.so
Configuration : system
I tried creating a java.opts file as suggested here. It did not make a difference.
I tried uninstalling and reinstalling matlab. It did not make a difference.
I had never set a MATLAB_JAVA variable, setting/unsetting it does not make a difference.
Any advice appreciated.I am on Manjaro Linux and I installed Matlab R2024b.
When trying to start Matlab, I get the following error :
Cannot locate or initialize class com/mathworks/jmi/OpaqueJavaInterface.
java.lang.NoClassDefFoundError: com/mathworks/jmi/OpaqueJavaInterface
Caused by: java.lang.ClassNotFoundException: com.mathworks.jmi.OpaqueJavaInterface
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
I tried changing the java version used by using matlab_jenv to switch to the default version on my machine, 1.7. It did not make a difference. Command:
sudo ./matlab_jenv -allusers system 1 ✘
Result: 1 ✘
JavaEnvironment with properties
Version : openjdk version "17.0.13" 2024-10-15
OpenJDK Runtime Environment (build 17.0.13+11)
OpenJDK 64-Bit Server VM (build 17.0.13+11, mixed mode, sharing)
Home : /usr/lib/jvm/java-17-openjdk
Library : /usr/lib/jvm/java-17-openjdk/lib/server/libjvm.so
Configuration : system
I tried creating a java.opts file as suggested here. It did not make a difference.
I tried uninstalling and reinstalling matlab. It did not make a difference.
I had never set a MATLAB_JAVA variable, setting/unsetting it does not make a difference.
Any advice appreciated. I am on Manjaro Linux and I installed Matlab R2024b.
When trying to start Matlab, I get the following error :
Cannot locate or initialize class com/mathworks/jmi/OpaqueJavaInterface.
java.lang.NoClassDefFoundError: com/mathworks/jmi/OpaqueJavaInterface
Caused by: java.lang.ClassNotFoundException: com.mathworks.jmi.OpaqueJavaInterface
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
I tried changing the java version used by using matlab_jenv to switch to the default version on my machine, 1.7. It did not make a difference. Command:
sudo ./matlab_jenv -allusers system 1 ✘
Result: 1 ✘
JavaEnvironment with properties
Version : openjdk version "17.0.13" 2024-10-15
OpenJDK Runtime Environment (build 17.0.13+11)
OpenJDK 64-Bit Server VM (build 17.0.13+11, mixed mode, sharing)
Home : /usr/lib/jvm/java-17-openjdk
Library : /usr/lib/jvm/java-17-openjdk/lib/server/libjvm.so
Configuration : system
I tried creating a java.opts file as suggested here. It did not make a difference.
I tried uninstalling and reinstalling matlab. It did not make a difference.
I had never set a MATLAB_JAVA variable, setting/unsetting it does not make a difference.
Any advice appreciated. installation, error, java MATLAB Answers — New Questions
Trying to create a drop down that will open a new uifigure, nothing happens when I click confirm?
Im writting a program to process data from different autonomous vehicles. I have 5 different vehicles that I can run and each of their data sets are recorded differently with different options, I have written a robust program that does alot of different things but only for 1 vehicle. Now im trying to expand this program but allowing the user to select the vehicle they ran and want to process. Below is what I have so far:
function [name, dd2_option] = programName()
%//////////////////////////////////////////////////////////////////////////
%////////////////////// VEHICLE SELECTION ////////////////////
%//////////////////////////////////////////////////////////////////////////
%create a small figure to show the pop up menu
fig1 = uifigure(‘Name’, ‘Drop Down Menu’, ‘Position’, [500, 500, 200, 150]);
%figure text
uilabel(fig1, …
‘Text’, ‘Select Vehicle:’, …
‘Position’, [25, 90, 120, 30], …
‘FontSize’, 14);
%drop down menu
dda = uidropdown(fig1, ‘Position’, [25, 50, 120, 30]);
dda.Items = ["Vehicle Selection", ‘USV-1’, ‘USV-2’, ‘AUGV’, ‘UUV’, ‘ROV’];
dda.ItemsData = [0, 1, 2, 3, 4, 5];
%confirm button
btna = uibutton(fig1,’Position’,[25, 10, 120, 30],’Text’,’Confirm’,’ButtonPushedFcn’,@(btn, event) confirmSelection(dda.Value));
%function to determine which dd option was selected
function confirmSelection(selectedOption)
switch selectedOption
case ‘USV-1’
usv1Figure()
case ‘USV-2’
usv2Figure()
case ‘AUGV’
augvFigure()
case ‘UUV’
uuvFigure()
case ‘ROV’
rovFigure()
end
end
function usv1Figure()
delete(fig1)
%start the program for USV1
When I run the code fig1 pops up with my drop down and I can select which option I want. Right now the only value that works is ‘USV-1’ option, when select that nothing happens. What I think it should do is close fig1 with the drop down and open fig2 to start my program. like I said, nothing happens, I dont get any warnings or errors in the command window, fig1 doesnt close, and fig2 doesnt open. Nothing happens. Where am I going wrong? Before I added this I had no issues running my program. Thanks in advance to any help you can give!Im writting a program to process data from different autonomous vehicles. I have 5 different vehicles that I can run and each of their data sets are recorded differently with different options, I have written a robust program that does alot of different things but only for 1 vehicle. Now im trying to expand this program but allowing the user to select the vehicle they ran and want to process. Below is what I have so far:
function [name, dd2_option] = programName()
%//////////////////////////////////////////////////////////////////////////
%////////////////////// VEHICLE SELECTION ////////////////////
%//////////////////////////////////////////////////////////////////////////
%create a small figure to show the pop up menu
fig1 = uifigure(‘Name’, ‘Drop Down Menu’, ‘Position’, [500, 500, 200, 150]);
%figure text
uilabel(fig1, …
‘Text’, ‘Select Vehicle:’, …
‘Position’, [25, 90, 120, 30], …
‘FontSize’, 14);
%drop down menu
dda = uidropdown(fig1, ‘Position’, [25, 50, 120, 30]);
dda.Items = ["Vehicle Selection", ‘USV-1’, ‘USV-2’, ‘AUGV’, ‘UUV’, ‘ROV’];
dda.ItemsData = [0, 1, 2, 3, 4, 5];
%confirm button
btna = uibutton(fig1,’Position’,[25, 10, 120, 30],’Text’,’Confirm’,’ButtonPushedFcn’,@(btn, event) confirmSelection(dda.Value));
%function to determine which dd option was selected
function confirmSelection(selectedOption)
switch selectedOption
case ‘USV-1’
usv1Figure()
case ‘USV-2’
usv2Figure()
case ‘AUGV’
augvFigure()
case ‘UUV’
uuvFigure()
case ‘ROV’
rovFigure()
end
end
function usv1Figure()
delete(fig1)
%start the program for USV1
When I run the code fig1 pops up with my drop down and I can select which option I want. Right now the only value that works is ‘USV-1’ option, when select that nothing happens. What I think it should do is close fig1 with the drop down and open fig2 to start my program. like I said, nothing happens, I dont get any warnings or errors in the command window, fig1 doesnt close, and fig2 doesnt open. Nothing happens. Where am I going wrong? Before I added this I had no issues running my program. Thanks in advance to any help you can give! Im writting a program to process data from different autonomous vehicles. I have 5 different vehicles that I can run and each of their data sets are recorded differently with different options, I have written a robust program that does alot of different things but only for 1 vehicle. Now im trying to expand this program but allowing the user to select the vehicle they ran and want to process. Below is what I have so far:
function [name, dd2_option] = programName()
%//////////////////////////////////////////////////////////////////////////
%////////////////////// VEHICLE SELECTION ////////////////////
%//////////////////////////////////////////////////////////////////////////
%create a small figure to show the pop up menu
fig1 = uifigure(‘Name’, ‘Drop Down Menu’, ‘Position’, [500, 500, 200, 150]);
%figure text
uilabel(fig1, …
‘Text’, ‘Select Vehicle:’, …
‘Position’, [25, 90, 120, 30], …
‘FontSize’, 14);
%drop down menu
dda = uidropdown(fig1, ‘Position’, [25, 50, 120, 30]);
dda.Items = ["Vehicle Selection", ‘USV-1’, ‘USV-2’, ‘AUGV’, ‘UUV’, ‘ROV’];
dda.ItemsData = [0, 1, 2, 3, 4, 5];
%confirm button
btna = uibutton(fig1,’Position’,[25, 10, 120, 30],’Text’,’Confirm’,’ButtonPushedFcn’,@(btn, event) confirmSelection(dda.Value));
%function to determine which dd option was selected
function confirmSelection(selectedOption)
switch selectedOption
case ‘USV-1’
usv1Figure()
case ‘USV-2’
usv2Figure()
case ‘AUGV’
augvFigure()
case ‘UUV’
uuvFigure()
case ‘ROV’
rovFigure()
end
end
function usv1Figure()
delete(fig1)
%start the program for USV1
When I run the code fig1 pops up with my drop down and I can select which option I want. Right now the only value that works is ‘USV-1’ option, when select that nothing happens. What I think it should do is close fig1 with the drop down and open fig2 to start my program. like I said, nothing happens, I dont get any warnings or errors in the command window, fig1 doesnt close, and fig2 doesnt open. Nothing happens. Where am I going wrong? Before I added this I had no issues running my program. Thanks in advance to any help you can give! uifigure MATLAB Answers — New Questions
Reading Arduino Serial Port into Matlab and 50% of the time getting characters instead of digits.
Exactly as the title says.
Trying to read serial values from an Arduino serial port into a matlab array. The sensor we’re reading from is a heartrate sensor from https://pulsesensor.com/. This is for a science fair project where a full collection is about 30 seconds long and then it is broken into chunks of 500 datapoints. So 6 trials from one collection. 60% of the time we’ll get a sensor reading that is in a doubles format but that other 40% the code seems to read extra characters and defaults back into characters. These characters aren’t random letters either but have plenty of accents and such. (example below the code)
We dont have trouble connecting to the board and when the data is being printed into the matlab command window it shoes numberical values ranging from 0 – 750 depending on the signal voltage. Its only after the loop that the file converts into a char array (usually 3005×1).
Any suggestions on how to ensure that the file stays in double and doesnt convert into a character array? I think it might have to do with the sampling frequency and aligning the arduino with the matlab code reading it but I’m not very familar with the process. Any suggestions would be greatly appreciated.
% Define the port where Arduino is connected
arduinoPort = ‘COM3’; % Replace ‘COM3’ with your actual port
baudRate = 9600; % Set the baud rate to match the Arduino’s baud rate
s = serial(arduinoPort, ‘BaudRate’, baudRate); % Create a serial object for the Arduino
% Initialize an empty array to store PPG data
ppgData = [];
numSamples = 3000; % Set the number of samples to collect (can be adjusted)
disp(‘Collecting PPG data…’); % Display message indicating data collection has started
j=1
fopen(s); % Open the serial port for communication
while j < numSamples+1
% Check if there is data available in the serial buffer
if s.BytesAvailable > 0
i = 1:numSamples; % Loop to collect the specified number of samples
% Read data from the serial port as a string and convert to an integer
data = fscanf(s, ‘%d’);
disp(data); % Display the received data to verify if values are being read
ppgData = [ppgData, data]; % Append the new data to the PPG data array
j=j+1;
%pause(0.01); % Pause for 10 milliseconds to allow time for new data to arrive
else
disp(‘No data available in buffer.’); % Warn if no data is available
end
pause(0.01); % Pause for 10 milliseconds to allow time for new data to arrive
end
ppgData = ppgData’;
data = reshape(ppgData, [500, 6]);
‘¼’
‘Ç’
‘Ì’
‘Ê’
‘à’
‘à’
‘ç’
‘ó’
‘ñ’
‘Ā’
‘ý’
‘û’
‘Ă’
‘ó’
‘ò’
‘ì’
‘×’
‘ß’
‘Î’
‘Ç’
‘¿’
‘«’
‘«Exactly as the title says.
Trying to read serial values from an Arduino serial port into a matlab array. The sensor we’re reading from is a heartrate sensor from https://pulsesensor.com/. This is for a science fair project where a full collection is about 30 seconds long and then it is broken into chunks of 500 datapoints. So 6 trials from one collection. 60% of the time we’ll get a sensor reading that is in a doubles format but that other 40% the code seems to read extra characters and defaults back into characters. These characters aren’t random letters either but have plenty of accents and such. (example below the code)
We dont have trouble connecting to the board and when the data is being printed into the matlab command window it shoes numberical values ranging from 0 – 750 depending on the signal voltage. Its only after the loop that the file converts into a char array (usually 3005×1).
Any suggestions on how to ensure that the file stays in double and doesnt convert into a character array? I think it might have to do with the sampling frequency and aligning the arduino with the matlab code reading it but I’m not very familar with the process. Any suggestions would be greatly appreciated.
% Define the port where Arduino is connected
arduinoPort = ‘COM3’; % Replace ‘COM3’ with your actual port
baudRate = 9600; % Set the baud rate to match the Arduino’s baud rate
s = serial(arduinoPort, ‘BaudRate’, baudRate); % Create a serial object for the Arduino
% Initialize an empty array to store PPG data
ppgData = [];
numSamples = 3000; % Set the number of samples to collect (can be adjusted)
disp(‘Collecting PPG data…’); % Display message indicating data collection has started
j=1
fopen(s); % Open the serial port for communication
while j < numSamples+1
% Check if there is data available in the serial buffer
if s.BytesAvailable > 0
i = 1:numSamples; % Loop to collect the specified number of samples
% Read data from the serial port as a string and convert to an integer
data = fscanf(s, ‘%d’);
disp(data); % Display the received data to verify if values are being read
ppgData = [ppgData, data]; % Append the new data to the PPG data array
j=j+1;
%pause(0.01); % Pause for 10 milliseconds to allow time for new data to arrive
else
disp(‘No data available in buffer.’); % Warn if no data is available
end
pause(0.01); % Pause for 10 milliseconds to allow time for new data to arrive
end
ppgData = ppgData’;
data = reshape(ppgData, [500, 6]);
‘¼’
‘Ç’
‘Ì’
‘Ê’
‘à’
‘à’
‘ç’
‘ó’
‘ñ’
‘Ā’
‘ý’
‘û’
‘Ă’
‘ó’
‘ò’
‘ì’
‘×’
‘ß’
‘Î’
‘Ç’
‘¿’
‘«’
‘« Exactly as the title says.
Trying to read serial values from an Arduino serial port into a matlab array. The sensor we’re reading from is a heartrate sensor from https://pulsesensor.com/. This is for a science fair project where a full collection is about 30 seconds long and then it is broken into chunks of 500 datapoints. So 6 trials from one collection. 60% of the time we’ll get a sensor reading that is in a doubles format but that other 40% the code seems to read extra characters and defaults back into characters. These characters aren’t random letters either but have plenty of accents and such. (example below the code)
We dont have trouble connecting to the board and when the data is being printed into the matlab command window it shoes numberical values ranging from 0 – 750 depending on the signal voltage. Its only after the loop that the file converts into a char array (usually 3005×1).
Any suggestions on how to ensure that the file stays in double and doesnt convert into a character array? I think it might have to do with the sampling frequency and aligning the arduino with the matlab code reading it but I’m not very familar with the process. Any suggestions would be greatly appreciated.
% Define the port where Arduino is connected
arduinoPort = ‘COM3’; % Replace ‘COM3’ with your actual port
baudRate = 9600; % Set the baud rate to match the Arduino’s baud rate
s = serial(arduinoPort, ‘BaudRate’, baudRate); % Create a serial object for the Arduino
% Initialize an empty array to store PPG data
ppgData = [];
numSamples = 3000; % Set the number of samples to collect (can be adjusted)
disp(‘Collecting PPG data…’); % Display message indicating data collection has started
j=1
fopen(s); % Open the serial port for communication
while j < numSamples+1
% Check if there is data available in the serial buffer
if s.BytesAvailable > 0
i = 1:numSamples; % Loop to collect the specified number of samples
% Read data from the serial port as a string and convert to an integer
data = fscanf(s, ‘%d’);
disp(data); % Display the received data to verify if values are being read
ppgData = [ppgData, data]; % Append the new data to the PPG data array
j=j+1;
%pause(0.01); % Pause for 10 milliseconds to allow time for new data to arrive
else
disp(‘No data available in buffer.’); % Warn if no data is available
end
pause(0.01); % Pause for 10 milliseconds to allow time for new data to arrive
end
ppgData = ppgData’;
data = reshape(ppgData, [500, 6]);
‘¼’
‘Ç’
‘Ì’
‘Ê’
‘à’
‘à’
‘ç’
‘ó’
‘ñ’
‘Ā’
‘ý’
‘û’
‘Ă’
‘ó’
‘ò’
‘ì’
‘×’
‘ß’
‘Î’
‘Ç’
‘¿’
‘«’
‘« arduino, fscanf, char, arduino serial MATLAB Answers — New Questions
3D poisson for electrostatics using solvepde
These are coordinates of atoms:
[1.8150 3.6300 6.2895;
3.6300 1.8150 7.5000;
3.6300 1.8150 5.0789;
-2.7225 4.7186 6.2895;
0.9075 6.5336 7.5000;
0.9075 6.5336 5.0789;
2.7225 4.7186 6.2895;
6.3525 6.5336 7.5000;
6.3525 6.5336 5.0789;
0 9.4373 6.2895;
3.6300 11.2523 7.5000;
3.6300 11.2523 5.0789;
5.4450 9.4373 6.2895;
9.0750 11.2523 7.5000;
9.0750 11.2523 5.0789;
2.7225 14.1559 6.2895];
There are 16 atoms. I get a row matrix of charge density(rho) from negf solver of size 1×16. x axis is the transport direction with bias voltage 0.5V. in z axis I apply electric field of 5V. In y axis electrostatic doesn’t change. I want dirichlet boundary condition in x axis. Neumann boundary in z axis. Periodic in y axis. All atoms with lowest & highest x values correspond to boundary in x direction. And atoms with lowest & highest z values correspond to boundary in z direction. Poisson equation to be solve is in form Del^2U(x,y,z)=-rho(x,y,z)/epsilon. Any guide on how to do it using solvepde?These are coordinates of atoms:
[1.8150 3.6300 6.2895;
3.6300 1.8150 7.5000;
3.6300 1.8150 5.0789;
-2.7225 4.7186 6.2895;
0.9075 6.5336 7.5000;
0.9075 6.5336 5.0789;
2.7225 4.7186 6.2895;
6.3525 6.5336 7.5000;
6.3525 6.5336 5.0789;
0 9.4373 6.2895;
3.6300 11.2523 7.5000;
3.6300 11.2523 5.0789;
5.4450 9.4373 6.2895;
9.0750 11.2523 7.5000;
9.0750 11.2523 5.0789;
2.7225 14.1559 6.2895];
There are 16 atoms. I get a row matrix of charge density(rho) from negf solver of size 1×16. x axis is the transport direction with bias voltage 0.5V. in z axis I apply electric field of 5V. In y axis electrostatic doesn’t change. I want dirichlet boundary condition in x axis. Neumann boundary in z axis. Periodic in y axis. All atoms with lowest & highest x values correspond to boundary in x direction. And atoms with lowest & highest z values correspond to boundary in z direction. Poisson equation to be solve is in form Del^2U(x,y,z)=-rho(x,y,z)/epsilon. Any guide on how to do it using solvepde? These are coordinates of atoms:
[1.8150 3.6300 6.2895;
3.6300 1.8150 7.5000;
3.6300 1.8150 5.0789;
-2.7225 4.7186 6.2895;
0.9075 6.5336 7.5000;
0.9075 6.5336 5.0789;
2.7225 4.7186 6.2895;
6.3525 6.5336 7.5000;
6.3525 6.5336 5.0789;
0 9.4373 6.2895;
3.6300 11.2523 7.5000;
3.6300 11.2523 5.0789;
5.4450 9.4373 6.2895;
9.0750 11.2523 7.5000;
9.0750 11.2523 5.0789;
2.7225 14.1559 6.2895];
There are 16 atoms. I get a row matrix of charge density(rho) from negf solver of size 1×16. x axis is the transport direction with bias voltage 0.5V. in z axis I apply electric field of 5V. In y axis electrostatic doesn’t change. I want dirichlet boundary condition in x axis. Neumann boundary in z axis. Periodic in y axis. All atoms with lowest & highest x values correspond to boundary in x direction. And atoms with lowest & highest z values correspond to boundary in z direction. Poisson equation to be solve is in form Del^2U(x,y,z)=-rho(x,y,z)/epsilon. Any guide on how to do it using solvepde? solvepde, 3d poisson for electrostatics MATLAB Answers — New Questions
Numerical Integration inc. a Sumation in equation
I have a sumation in the equation i need to integrate,
syms k;
symsum(sym(‘k’), k, 0, 10)
works fine, as does
X = 0:1:10; Y = X.^2; Z = trapz(X,Y)
however I need to somehow combine them, like
X = 0:1:10; Y = X.^2*symsum(sym(‘X’), X, 0, 10); Z = trapz(X,Y)
but this just gives the error
??? Undefined function or method ‘normalizesym’ for input arguments of type ‘double’.
Error in ==> sym.symsum at 65
if builtin(‘numel’,x) ~= 1, x = normalizesym(x); end
How can I put a equation that is summed over a range of values, into an equation that is then numerically integrated?
(p.s. For reasons out of my control I have a nasty density fn with a summation expression nested within it, which then gets put into another density function which has to be numerically integrated. The above is a just a simple example as Im struggling to get the basics right before tackeling the monster I have to integrate!I have a sumation in the equation i need to integrate,
syms k;
symsum(sym(‘k’), k, 0, 10)
works fine, as does
X = 0:1:10; Y = X.^2; Z = trapz(X,Y)
however I need to somehow combine them, like
X = 0:1:10; Y = X.^2*symsum(sym(‘X’), X, 0, 10); Z = trapz(X,Y)
but this just gives the error
??? Undefined function or method ‘normalizesym’ for input arguments of type ‘double’.
Error in ==> sym.symsum at 65
if builtin(‘numel’,x) ~= 1, x = normalizesym(x); end
How can I put a equation that is summed over a range of values, into an equation that is then numerically integrated?
(p.s. For reasons out of my control I have a nasty density fn with a summation expression nested within it, which then gets put into another density function which has to be numerically integrated. The above is a just a simple example as Im struggling to get the basics right before tackeling the monster I have to integrate! I have a sumation in the equation i need to integrate,
syms k;
symsum(sym(‘k’), k, 0, 10)
works fine, as does
X = 0:1:10; Y = X.^2; Z = trapz(X,Y)
however I need to somehow combine them, like
X = 0:1:10; Y = X.^2*symsum(sym(‘X’), X, 0, 10); Z = trapz(X,Y)
but this just gives the error
??? Undefined function or method ‘normalizesym’ for input arguments of type ‘double’.
Error in ==> sym.symsum at 65
if builtin(‘numel’,x) ~= 1, x = normalizesym(x); end
How can I put a equation that is summed over a range of values, into an equation that is then numerically integrated?
(p.s. For reasons out of my control I have a nasty density fn with a summation expression nested within it, which then gets put into another density function which has to be numerically integrated. The above is a just a simple example as Im struggling to get the basics right before tackeling the monster I have to integrate! numerical, integration, summation, combine, trapz MATLAB Answers — New Questions
How can I write Log messages from FMU exported from MATLAB/Simulink
An FMU can issue log messages througt the fmiCallbackLogger member of the fmiCallbackFunction.
I have an FMU that is exported from Simulink (version 2024) that has a ‘MATLAB Function’ block that contains MATLAB code.
How can I write FMU log messages from the MATLAB code inside this block?
If I enable ‘Debug Logging’ in the fmpy.gui tool I can indeed see log messages coming from MATLAB :
CommunicationStepSize=0.2, LocalSolverStepSize=0.2
Local solver will do 1 steps from t = 0.2.
getReal vr:0, value:0.000000
getReal vr:1, value:0.000000
getReal vr:2, value:0.000000
getReal vr:3, value:0.000000
getReal vr:4, va lue:0.000000
But how do I add my own log messages?An FMU can issue log messages througt the fmiCallbackLogger member of the fmiCallbackFunction.
I have an FMU that is exported from Simulink (version 2024) that has a ‘MATLAB Function’ block that contains MATLAB code.
How can I write FMU log messages from the MATLAB code inside this block?
If I enable ‘Debug Logging’ in the fmpy.gui tool I can indeed see log messages coming from MATLAB :
CommunicationStepSize=0.2, LocalSolverStepSize=0.2
Local solver will do 1 steps from t = 0.2.
getReal vr:0, value:0.000000
getReal vr:1, value:0.000000
getReal vr:2, value:0.000000
getReal vr:3, value:0.000000
getReal vr:4, va lue:0.000000
But how do I add my own log messages? An FMU can issue log messages througt the fmiCallbackLogger member of the fmiCallbackFunction.
I have an FMU that is exported from Simulink (version 2024) that has a ‘MATLAB Function’ block that contains MATLAB code.
How can I write FMU log messages from the MATLAB code inside this block?
If I enable ‘Debug Logging’ in the fmpy.gui tool I can indeed see log messages coming from MATLAB :
CommunicationStepSize=0.2, LocalSolverStepSize=0.2
Local solver will do 1 steps from t = 0.2.
getReal vr:0, value:0.000000
getReal vr:1, value:0.000000
getReal vr:2, value:0.000000
getReal vr:3, value:0.000000
getReal vr:4, va lue:0.000000
But how do I add my own log messages? fmi, fmu, logging MATLAB Answers — New Questions
Confine contour lines to region defined by data
I am using contour() to construct contour lines onto a 2D grid of data defined by the first two columns of "tog.txt," with the value defined by the third column. This data can have 10^3 or more rows. I would like to confine these lines to exist only in the region where the data exists.
I plot the scatter data as well as the border that bounds the data with boundary() for visualization.
The results of each attempt are attached. How can I ensure the contour lines are terminated by the data boundary?
togtxt = load(‘tog.txt’);
x1 = togtxt(:,1);
y1 = togtxt(:,2);
c1 = togtxt(:,3);
% —- customize figure ——————————————————-
f(1)=figure;
hold all
ax = gca;
set(gca,’LineWidth’,1.3,’TickLength’,[0.015 0.015],’plotboxaspectratio’,[1 1 1]); % size of ticks
set(gca,’ColorScale’,’log’)
xscale log
jjj = boundary(x1,y1);
plot(x1(jjj),y1(jjj));
scatter(togtxt(:,1),togtxt(:,2),2,’filled’);
N = 120;
%%% attempt 1
v1 = logspace(log10(min(c1)),log10(max(c1)),50);
I = scatteredInterpolant(x1,y1,c1);
X = linspace(min(x1),max(x1),N);
Y = linspace(min(y1),max(y1),N);
[X,Y] = meshgrid(X,Y);
Z = I(X,Y);
contour(X,Y,Z,v1);
colorbar
%%% attempt 2
% v1 = logspace(log10(min(c1)),log10(max(c1)),50);
% xv = linspace(min(x1),max(x1),N);
% yv = linspace(min(y1),max(y1),N); % will run out of memory unless N small
% [Xm,Ym] = ndgrid(xv,yv);
% MFm = griddata(x1,y1,c1,Xm,Ym);
% contour(Xm, Ym, MFm,v1)I am using contour() to construct contour lines onto a 2D grid of data defined by the first two columns of "tog.txt," with the value defined by the third column. This data can have 10^3 or more rows. I would like to confine these lines to exist only in the region where the data exists.
I plot the scatter data as well as the border that bounds the data with boundary() for visualization.
The results of each attempt are attached. How can I ensure the contour lines are terminated by the data boundary?
togtxt = load(‘tog.txt’);
x1 = togtxt(:,1);
y1 = togtxt(:,2);
c1 = togtxt(:,3);
% —- customize figure ——————————————————-
f(1)=figure;
hold all
ax = gca;
set(gca,’LineWidth’,1.3,’TickLength’,[0.015 0.015],’plotboxaspectratio’,[1 1 1]); % size of ticks
set(gca,’ColorScale’,’log’)
xscale log
jjj = boundary(x1,y1);
plot(x1(jjj),y1(jjj));
scatter(togtxt(:,1),togtxt(:,2),2,’filled’);
N = 120;
%%% attempt 1
v1 = logspace(log10(min(c1)),log10(max(c1)),50);
I = scatteredInterpolant(x1,y1,c1);
X = linspace(min(x1),max(x1),N);
Y = linspace(min(y1),max(y1),N);
[X,Y] = meshgrid(X,Y);
Z = I(X,Y);
contour(X,Y,Z,v1);
colorbar
%%% attempt 2
% v1 = logspace(log10(min(c1)),log10(max(c1)),50);
% xv = linspace(min(x1),max(x1),N);
% yv = linspace(min(y1),max(y1),N); % will run out of memory unless N small
% [Xm,Ym] = ndgrid(xv,yv);
% MFm = griddata(x1,y1,c1,Xm,Ym);
% contour(Xm, Ym, MFm,v1) I am using contour() to construct contour lines onto a 2D grid of data defined by the first two columns of "tog.txt," with the value defined by the third column. This data can have 10^3 or more rows. I would like to confine these lines to exist only in the region where the data exists.
I plot the scatter data as well as the border that bounds the data with boundary() for visualization.
The results of each attempt are attached. How can I ensure the contour lines are terminated by the data boundary?
togtxt = load(‘tog.txt’);
x1 = togtxt(:,1);
y1 = togtxt(:,2);
c1 = togtxt(:,3);
% —- customize figure ——————————————————-
f(1)=figure;
hold all
ax = gca;
set(gca,’LineWidth’,1.3,’TickLength’,[0.015 0.015],’plotboxaspectratio’,[1 1 1]); % size of ticks
set(gca,’ColorScale’,’log’)
xscale log
jjj = boundary(x1,y1);
plot(x1(jjj),y1(jjj));
scatter(togtxt(:,1),togtxt(:,2),2,’filled’);
N = 120;
%%% attempt 1
v1 = logspace(log10(min(c1)),log10(max(c1)),50);
I = scatteredInterpolant(x1,y1,c1);
X = linspace(min(x1),max(x1),N);
Y = linspace(min(y1),max(y1),N);
[X,Y] = meshgrid(X,Y);
Z = I(X,Y);
contour(X,Y,Z,v1);
colorbar
%%% attempt 2
% v1 = logspace(log10(min(c1)),log10(max(c1)),50);
% xv = linspace(min(x1),max(x1),N);
% yv = linspace(min(y1),max(y1),N); % will run out of memory unless N small
% [Xm,Ym] = ndgrid(xv,yv);
% MFm = griddata(x1,y1,c1,Xm,Ym);
% contour(Xm, Ym, MFm,v1) meshgrid, contour MATLAB Answers — New Questions
readtable error after r2014a –> r2022b upgrade
I have a script coded in MATLAB R2014a, running correctly. After intalling R2022b or later this line
t = readtable(‘test.txt’, ‘Delimiter’,’;’);
results in error:
Delimiter must be a string array, character vector, or cell array of character vectors.
Why?I have a script coded in MATLAB R2014a, running correctly. After intalling R2022b or later this line
t = readtable(‘test.txt’, ‘Delimiter’,’;’);
results in error:
Delimiter must be a string array, character vector, or cell array of character vectors.
Why? I have a script coded in MATLAB R2014a, running correctly. After intalling R2022b or later this line
t = readtable(‘test.txt’, ‘Delimiter’,’;’);
results in error:
Delimiter must be a string array, character vector, or cell array of character vectors.
Why? readtable, delimiter, error, r2022b MATLAB Answers — New Questions
Using Hardware Interrupt with STM32 Nucleo F767ZI board
I want to use a hardware interrupt, in particular, the TXE flag on Simulink, however I have found that there does not appear to be a hardware interrupt block in the simulink support package for stm32 nucleo boards.
The hardware interrupt blocks for STM32F4 Discovery and the ARM Cortex-Mx don’t give any errors but I cannot imagine that using them would be correct.
Is there a way to get the TXE flag for the STM32 Nucleo F767ZI on simulink or should I just restart my project on the STM32CubeIDE instead.I want to use a hardware interrupt, in particular, the TXE flag on Simulink, however I have found that there does not appear to be a hardware interrupt block in the simulink support package for stm32 nucleo boards.
The hardware interrupt blocks for STM32F4 Discovery and the ARM Cortex-Mx don’t give any errors but I cannot imagine that using them would be correct.
Is there a way to get the TXE flag for the STM32 Nucleo F767ZI on simulink or should I just restart my project on the STM32CubeIDE instead. I want to use a hardware interrupt, in particular, the TXE flag on Simulink, however I have found that there does not appear to be a hardware interrupt block in the simulink support package for stm32 nucleo boards.
The hardware interrupt blocks for STM32F4 Discovery and the ARM Cortex-Mx don’t give any errors but I cannot imagine that using them would be correct.
Is there a way to get the TXE flag for the STM32 Nucleo F767ZI on simulink or should I just restart my project on the STM32CubeIDE instead. simulink, embedded coder MATLAB Answers — New Questions
Help to plot a Surface plot of: z = y sin x – x cos y
Require help on plotting this suface plot for the fuction:
z = y sin x – x cos y
using a grid of:
-5<x<5 in steps of 0.2
-5<y<5 in steps of 0.2
Any guidance would be much appreciated
ThanksRequire help on plotting this suface plot for the fuction:
z = y sin x – x cos y
using a grid of:
-5<x<5 in steps of 0.2
-5<y<5 in steps of 0.2
Any guidance would be much appreciated
Thanks Require help on plotting this suface plot for the fuction:
z = y sin x – x cos y
using a grid of:
-5<x<5 in steps of 0.2
-5<y<5 in steps of 0.2
Any guidance would be much appreciated
Thanks surface plot, grid, matlab function, equation, homework MATLAB Answers — New Questions
Best way to plot a surface whose matrix has values of +/- infinity
Hi there! What is the best way to plot a 3D surface whose matrix C = A/B contains values of +/- infinity (whenever entries in B are zero)? Currently I am using surf( ), which results in weird vertical cross sections. I looked into the fillMissing( ) and scatteredInterpolant( ) functions. Is there a best / recommended way to proceed, to plot a smooth surface? Thanks in advance,Hi there! What is the best way to plot a 3D surface whose matrix C = A/B contains values of +/- infinity (whenever entries in B are zero)? Currently I am using surf( ), which results in weird vertical cross sections. I looked into the fillMissing( ) and scatteredInterpolant( ) functions. Is there a best / recommended way to proceed, to plot a smooth surface? Thanks in advance, Hi there! What is the best way to plot a 3D surface whose matrix C = A/B contains values of +/- infinity (whenever entries in B are zero)? Currently I am using surf( ), which results in weird vertical cross sections. I looked into the fillMissing( ) and scatteredInterpolant( ) functions. Is there a best / recommended way to proceed, to plot a smooth surface? Thanks in advance, matlab surface plot singularities MATLAB Answers — New Questions