Tag Archives: matlab
How can I dynamically create and configure a subclass of an abstract class from a file or script in one step in MATLAB?
In MATLAB, I have an abstract class called "Vehicle" and concrete subclasses like "Car" and "Bike". In my "Garage" class, the "vehicle" property is set dynamically at runtime by reading a config script (e.g., "garageConfig.m"). Right now, I use a variable "vehicleType" in "garageConfig.m" to determine which subclass to instantiate. But the problem is I have to:Run "garageConfig.m" to get the value for "vehicleType", then set the property "vehicle" to the correct child (e.g., obj.vehicle = Bike()).Then run "garageConfig.m" again to populate the property values (like "vehicle.color", "vehicle.wheels", etc.) for the instantiated child class.
Is there a better way to do this, so I don’t have to run the config script twice to set up the "vehicle" object and its properties?
% Vehicle.m
classdef (Abstract) Vehicle
properties
color = "white";
wheels = 4;
end
end
% Car.m
classdef Car < Vehicle
end
% Bike.m
classdef Bike < Vehicle
properties
hasBell = false;
end
end
% Garage.m
classdef Garage
properties
vehicle % will be Vehicle
end
methods
function obj = Garage(configFile)
% First run: get vehicleType
run(configFile); % loads vehicleType and vehicle properties
% Instantiate correct subclass
switch vehicleType
case 1
obj.vehicle = Car();
case 2
obj.vehicle = Bike();
end
% Now, to assign properties, need to run the config file again:
run(configFile); % loads vehicle.color, vehicle.wheels, etc.
% Assign properties
obj.vehicle.color = vehicle.color;
obj.vehicle.wheels = vehicle.wheels;
if isa(obj.vehicle, ‘Bike’)
obj.vehicle.hasBell = vehicle.hasBell;
end
end
end
end
% garageConfig.m
vehicleType = 2; % 1 for Car, 2 for Bike
vehicle.color = "red";
vehicle.wheels = 2;
vehicle.hasBell = true;
% Usage:
g = Garage(‘garageConfig.m’);In MATLAB, I have an abstract class called "Vehicle" and concrete subclasses like "Car" and "Bike". In my "Garage" class, the "vehicle" property is set dynamically at runtime by reading a config script (e.g., "garageConfig.m"). Right now, I use a variable "vehicleType" in "garageConfig.m" to determine which subclass to instantiate. But the problem is I have to:Run "garageConfig.m" to get the value for "vehicleType", then set the property "vehicle" to the correct child (e.g., obj.vehicle = Bike()).Then run "garageConfig.m" again to populate the property values (like "vehicle.color", "vehicle.wheels", etc.) for the instantiated child class.
Is there a better way to do this, so I don’t have to run the config script twice to set up the "vehicle" object and its properties?
% Vehicle.m
classdef (Abstract) Vehicle
properties
color = "white";
wheels = 4;
end
end
% Car.m
classdef Car < Vehicle
end
% Bike.m
classdef Bike < Vehicle
properties
hasBell = false;
end
end
% Garage.m
classdef Garage
properties
vehicle % will be Vehicle
end
methods
function obj = Garage(configFile)
% First run: get vehicleType
run(configFile); % loads vehicleType and vehicle properties
% Instantiate correct subclass
switch vehicleType
case 1
obj.vehicle = Car();
case 2
obj.vehicle = Bike();
end
% Now, to assign properties, need to run the config file again:
run(configFile); % loads vehicle.color, vehicle.wheels, etc.
% Assign properties
obj.vehicle.color = vehicle.color;
obj.vehicle.wheels = vehicle.wheels;
if isa(obj.vehicle, ‘Bike’)
obj.vehicle.hasBell = vehicle.hasBell;
end
end
end
end
% garageConfig.m
vehicleType = 2; % 1 for Car, 2 for Bike
vehicle.color = "red";
vehicle.wheels = 2;
vehicle.hasBell = true;
% Usage:
g = Garage(‘garageConfig.m’); In MATLAB, I have an abstract class called "Vehicle" and concrete subclasses like "Car" and "Bike". In my "Garage" class, the "vehicle" property is set dynamically at runtime by reading a config script (e.g., "garageConfig.m"). Right now, I use a variable "vehicleType" in "garageConfig.m" to determine which subclass to instantiate. But the problem is I have to:Run "garageConfig.m" to get the value for "vehicleType", then set the property "vehicle" to the correct child (e.g., obj.vehicle = Bike()).Then run "garageConfig.m" again to populate the property values (like "vehicle.color", "vehicle.wheels", etc.) for the instantiated child class.
Is there a better way to do this, so I don’t have to run the config script twice to set up the "vehicle" object and its properties?
% Vehicle.m
classdef (Abstract) Vehicle
properties
color = "white";
wheels = 4;
end
end
% Car.m
classdef Car < Vehicle
end
% Bike.m
classdef Bike < Vehicle
properties
hasBell = false;
end
end
% Garage.m
classdef Garage
properties
vehicle % will be Vehicle
end
methods
function obj = Garage(configFile)
% First run: get vehicleType
run(configFile); % loads vehicleType and vehicle properties
% Instantiate correct subclass
switch vehicleType
case 1
obj.vehicle = Car();
case 2
obj.vehicle = Bike();
end
% Now, to assign properties, need to run the config file again:
run(configFile); % loads vehicle.color, vehicle.wheels, etc.
% Assign properties
obj.vehicle.color = vehicle.color;
obj.vehicle.wheels = vehicle.wheels;
if isa(obj.vehicle, ‘Bike’)
obj.vehicle.hasBell = vehicle.hasBell;
end
end
end
end
% garageConfig.m
vehicleType = 2; % 1 for Car, 2 for Bike
vehicle.color = "red";
vehicle.wheels = 2;
vehicle.hasBell = true;
% Usage:
g = Garage(‘garageConfig.m’); abstractclass, subclass, classconfig MATLAB Answers — New Questions
Request to Change Account Type from Student to Educator/Researcher
Hello,
I recently created a MathWorks account, but I accidentally selected the “Student” profile during the registration process.
I actually need to use MATLAB for teaching and academic research purposes, so I would like to change my account type to “Educator/Researcher.”
My university email address is: [removed]
Could you please update my account accordingly or guide me through the necessary steps to make this change?
Thank you in advance for your assistance.
Best regards,Hello,
I recently created a MathWorks account, but I accidentally selected the “Student” profile during the registration process.
I actually need to use MATLAB for teaching and academic research purposes, so I would like to change my account type to “Educator/Researcher.”
My university email address is: [removed]
Could you please update my account accordingly or guide me through the necessary steps to make this change?
Thank you in advance for your assistance.
Best regards, Hello,
I recently created a MathWorks account, but I accidentally selected the “Student” profile during the registration process.
I actually need to use MATLAB for teaching and academic research purposes, so I would like to change my account type to “Educator/Researcher.”
My university email address is: [removed]
Could you please update my account accordingly or guide me through the necessary steps to make this change?
Thank you in advance for your assistance.
Best regards, profile MATLAB Answers — New Questions
How to access to i2c Qwiic connector on Arduino Uno R4Wifi?
I am using an Arduino UnoR4Wifi to read i2c accelerometer (LiS3DH) in Matlab and Simulink. This works ok using i2c Bus 0, with the accelerometer wires individually plugged into the board (A4,A5,3.3v,Gr). But I want to use the in-built ‘Qwiic’ connector on the Arduino board (aka ‘StemmaQT’ connector) for convenient plug-and-play access so I can quickly attach/detach sensors during an experiment.
However, when i attach the accelerometer to the Qwiic connector (Bus 1) it is not recognised by Matlab. I have tried using pull-down resistors attached to the SDA/SCL connections to activate Bus 1, to no avail. I am not sure if this is a Matlab software limitation, or an Arduino hardware limitation. Matlab suggests Bus 1 is not valid (see code below with no accelerometer attached), so i am guessing it might be a software limitation.
Any advice appreciated!
Raymond
>
> a = arduino(‘COM7’, ‘UnoR4WiFi’, ‘Libraries’, ‘I2C’);
>> scanI2CBus(a,0)
Device not detected on I2C Bus 0. Make sure the I2C device is properly connected to pins A4(SDA) and A5(SCL).
>> scanI2CBus(a,1)
Invalid I2C bus ID. Valid bus IDs are 0I am using an Arduino UnoR4Wifi to read i2c accelerometer (LiS3DH) in Matlab and Simulink. This works ok using i2c Bus 0, with the accelerometer wires individually plugged into the board (A4,A5,3.3v,Gr). But I want to use the in-built ‘Qwiic’ connector on the Arduino board (aka ‘StemmaQT’ connector) for convenient plug-and-play access so I can quickly attach/detach sensors during an experiment.
However, when i attach the accelerometer to the Qwiic connector (Bus 1) it is not recognised by Matlab. I have tried using pull-down resistors attached to the SDA/SCL connections to activate Bus 1, to no avail. I am not sure if this is a Matlab software limitation, or an Arduino hardware limitation. Matlab suggests Bus 1 is not valid (see code below with no accelerometer attached), so i am guessing it might be a software limitation.
Any advice appreciated!
Raymond
>
> a = arduino(‘COM7’, ‘UnoR4WiFi’, ‘Libraries’, ‘I2C’);
>> scanI2CBus(a,0)
Device not detected on I2C Bus 0. Make sure the I2C device is properly connected to pins A4(SDA) and A5(SCL).
>> scanI2CBus(a,1)
Invalid I2C bus ID. Valid bus IDs are 0 I am using an Arduino UnoR4Wifi to read i2c accelerometer (LiS3DH) in Matlab and Simulink. This works ok using i2c Bus 0, with the accelerometer wires individually plugged into the board (A4,A5,3.3v,Gr). But I want to use the in-built ‘Qwiic’ connector on the Arduino board (aka ‘StemmaQT’ connector) for convenient plug-and-play access so I can quickly attach/detach sensors during an experiment.
However, when i attach the accelerometer to the Qwiic connector (Bus 1) it is not recognised by Matlab. I have tried using pull-down resistors attached to the SDA/SCL connections to activate Bus 1, to no avail. I am not sure if this is a Matlab software limitation, or an Arduino hardware limitation. Matlab suggests Bus 1 is not valid (see code below with no accelerometer attached), so i am guessing it might be a software limitation.
Any advice appreciated!
Raymond
>
> a = arduino(‘COM7’, ‘UnoR4WiFi’, ‘Libraries’, ‘I2C’);
>> scanI2CBus(a,0)
Device not detected on I2C Bus 0. Make sure the I2C device is properly connected to pins A4(SDA) and A5(SCL).
>> scanI2CBus(a,1)
Invalid I2C bus ID. Valid bus IDs are 0 arduino, i2c, accelerometer, lis3dh, qwiic, stemmaqt MATLAB Answers — New Questions
Why is the “covInfo” output of the “mcdcinfo” function not necessarily “[0 0]” when the “description” output is an empty array in Simulink Coverage R2024b?
In Simulink Coverage R2024b, I am using the "mcdcinfo" function to query Modified Condition/Decision Coverage (MCDC) results.
I noticed that the "covInfo" (first) output is not necessarily "[0 0]" when the "description" (second) output is an empty array "[]".
Why is this the case?In Simulink Coverage R2024b, I am using the "mcdcinfo" function to query Modified Condition/Decision Coverage (MCDC) results.
I noticed that the "covInfo" (first) output is not necessarily "[0 0]" when the "description" (second) output is an empty array "[]".
Why is this the case? In Simulink Coverage R2024b, I am using the "mcdcinfo" function to query Modified Condition/Decision Coverage (MCDC) results.
I noticed that the "covInfo" (first) output is not necessarily "[0 0]" when the "description" (second) output is an empty array "[]".
Why is this the case? mcdcinfo, covinfo, description, mcdc, modelobject MATLAB Answers — New Questions
Matlab online docs showing in dark mode
The Matlab online docs (e.g., https://www.mathworks.com/help/?s_tid=user_nav_help ) showing in dark mode on mathworks.com are showing in dark mode for me. Is there a site setting to switch them back to light mode?The Matlab online docs (e.g., https://www.mathworks.com/help/?s_tid=user_nav_help ) showing in dark mode on mathworks.com are showing in dark mode for me. Is there a site setting to switch them back to light mode? The Matlab online docs (e.g., https://www.mathworks.com/help/?s_tid=user_nav_help ) showing in dark mode on mathworks.com are showing in dark mode for me. Is there a site setting to switch them back to light mode? matlab MATLAB Answers — New Questions
Call a Matlab function in Simulink for later code generation
Hello!
I need to use a MATLAB function in my Simulink project.
The problem is that this function needs to call other functions and load data from *.mat files (see image).
I also need to generate the code using Simulink Coder and Embedded Coder.
Which technique should I adopt from the answer below ?
Call a Matlab function in Simulink from the current folderHello!
I need to use a MATLAB function in my Simulink project.
The problem is that this function needs to call other functions and load data from *.mat files (see image).
I also need to generate the code using Simulink Coder and Embedded Coder.
Which technique should I adopt from the answer below ?
Call a Matlab function in Simulink from the current folder Hello!
I need to use a MATLAB function in my Simulink project.
The problem is that this function needs to call other functions and load data from *.mat files (see image).
I also need to generate the code using Simulink Coder and Embedded Coder.
Which technique should I adopt from the answer below ?
Call a Matlab function in Simulink from the current folder simulink, matlab, code generation, embedded matlab function, embedded coder MATLAB Answers — New Questions
How to find a function in the path – securely?
What is a safe method to check, where a specific function exists in Matlab’s path? It should not matter, if the function is an M, P or MEX file.
Actually, this is a job for which() . To avoid collisions with local variables, it should be hidden in a function:
function Reply = safeWhich(varargin)
Reply = which(varargin{:});
end
This fails for ‘varargin’, as expected:
safeWhich(‘varargin’)
But there are further traps
safeWhich(‘R’) % Same for ‘P’
In Matlab R2018b under Windows I get:
‘C:Program FilesMATLABR2018btoolboxmatlabcodetools@mtreemtree.m % mtree method’
The appended comment allowed to exclude the output by checking, if a corrensponding file exists:
function Reply = safeWhich_2(varargin)
Reply = which(varargin{:});
Reply = cellstr(Reply);
Reply = Reply(isfile(Reply)); % Worked in R2018b, no effect in R2025a
end
safeWhich_2(‘R’)
The exist() command does have the power to find functions properly, but it does not reveal where.
The old function depfun() was replaced by the ugly matlab.codetools.requiredFilesAndProducts(). I could search in the corresponding code, couldn’t I? This function uses the code find here internally: "toolboxmatlabdepfun+matlab+depfun+internal+whichcallWhich.m". Here I find 91 functions and 11.3 MB of code. One function looks like this:
% 10^(-18) is effective zero in terms of possibility, which requries
% log(10^18)/log(26+10+1) = 12 random letters, digits, or underscores.
function klno6phn_9faskf_na = callWhich(asm_foyan_knaouie8)
klno6phn_9faskf_na = which(asm_foyan_knaouie8);
end
Obviously MathWorks struggles with comparable problems.
The profiler shows, that matlab.codetools.requiredFilesAndProducts() calls 207 subfunctions (R2018b).
See the discussion: https://www.mathworks.com/matlabcentral/discussions/ideas/887763-i-have-been-a-matlab-loyalist-for-25-years . The complexity explodes, such that a simple task like searching a function file needs a pile of exceptions and indirections.What is a safe method to check, where a specific function exists in Matlab’s path? It should not matter, if the function is an M, P or MEX file.
Actually, this is a job for which() . To avoid collisions with local variables, it should be hidden in a function:
function Reply = safeWhich(varargin)
Reply = which(varargin{:});
end
This fails for ‘varargin’, as expected:
safeWhich(‘varargin’)
But there are further traps
safeWhich(‘R’) % Same for ‘P’
In Matlab R2018b under Windows I get:
‘C:Program FilesMATLABR2018btoolboxmatlabcodetools@mtreemtree.m % mtree method’
The appended comment allowed to exclude the output by checking, if a corrensponding file exists:
function Reply = safeWhich_2(varargin)
Reply = which(varargin{:});
Reply = cellstr(Reply);
Reply = Reply(isfile(Reply)); % Worked in R2018b, no effect in R2025a
end
safeWhich_2(‘R’)
The exist() command does have the power to find functions properly, but it does not reveal where.
The old function depfun() was replaced by the ugly matlab.codetools.requiredFilesAndProducts(). I could search in the corresponding code, couldn’t I? This function uses the code find here internally: "toolboxmatlabdepfun+matlab+depfun+internal+whichcallWhich.m". Here I find 91 functions and 11.3 MB of code. One function looks like this:
% 10^(-18) is effective zero in terms of possibility, which requries
% log(10^18)/log(26+10+1) = 12 random letters, digits, or underscores.
function klno6phn_9faskf_na = callWhich(asm_foyan_knaouie8)
klno6phn_9faskf_na = which(asm_foyan_knaouie8);
end
Obviously MathWorks struggles with comparable problems.
The profiler shows, that matlab.codetools.requiredFilesAndProducts() calls 207 subfunctions (R2018b).
See the discussion: https://www.mathworks.com/matlabcentral/discussions/ideas/887763-i-have-been-a-matlab-loyalist-for-25-years . The complexity explodes, such that a simple task like searching a function file needs a pile of exceptions and indirections. What is a safe method to check, where a specific function exists in Matlab’s path? It should not matter, if the function is an M, P or MEX file.
Actually, this is a job for which() . To avoid collisions with local variables, it should be hidden in a function:
function Reply = safeWhich(varargin)
Reply = which(varargin{:});
end
This fails for ‘varargin’, as expected:
safeWhich(‘varargin’)
But there are further traps
safeWhich(‘R’) % Same for ‘P’
In Matlab R2018b under Windows I get:
‘C:Program FilesMATLABR2018btoolboxmatlabcodetools@mtreemtree.m % mtree method’
The appended comment allowed to exclude the output by checking, if a corrensponding file exists:
function Reply = safeWhich_2(varargin)
Reply = which(varargin{:});
Reply = cellstr(Reply);
Reply = Reply(isfile(Reply)); % Worked in R2018b, no effect in R2025a
end
safeWhich_2(‘R’)
The exist() command does have the power to find functions properly, but it does not reveal where.
The old function depfun() was replaced by the ugly matlab.codetools.requiredFilesAndProducts(). I could search in the corresponding code, couldn’t I? This function uses the code find here internally: "toolboxmatlabdepfun+matlab+depfun+internal+whichcallWhich.m". Here I find 91 functions and 11.3 MB of code. One function looks like this:
% 10^(-18) is effective zero in terms of possibility, which requries
% log(10^18)/log(26+10+1) = 12 random letters, digits, or underscores.
function klno6phn_9faskf_na = callWhich(asm_foyan_knaouie8)
klno6phn_9faskf_na = which(asm_foyan_knaouie8);
end
Obviously MathWorks struggles with comparable problems.
The profiler shows, that matlab.codetools.requiredFilesAndProducts() calls 207 subfunctions (R2018b).
See the discussion: https://www.mathworks.com/matlabcentral/discussions/ideas/887763-i-have-been-a-matlab-loyalist-for-25-years . The complexity explodes, such that a simple task like searching a function file needs a pile of exceptions and indirections. which, exist, required products, file MATLAB Answers — New Questions
comm.SDRuReceiver on X310 throws receiveData:ErrLateCommand
I am trying to receive data from a USRP X310 in MATLAB using comm.SDRuReceiver, and I keep hitting the error:
Receive unsuccessfully: Could not execute UHD driver command in ‘receiveData_cont_c’: receiveData:ErrLateCommand. A stream command was issued in the past.
Running the benchmark_rate reports: * 0 dropped samples * 0 overflows * 0 late commands * 0 timeoutsI am trying to receive data from a USRP X310 in MATLAB using comm.SDRuReceiver, and I keep hitting the error:
Receive unsuccessfully: Could not execute UHD driver command in ‘receiveData_cont_c’: receiveData:ErrLateCommand. A stream command was issued in the past.
Running the benchmark_rate reports: * 0 dropped samples * 0 overflows * 0 late commands * 0 timeouts I am trying to receive data from a USRP X310 in MATLAB using comm.SDRuReceiver, and I keep hitting the error:
Receive unsuccessfully: Could not execute UHD driver command in ‘receiveData_cont_c’: receiveData:ErrLateCommand. A stream command was issued in the past.
Running the benchmark_rate reports: * 0 dropped samples * 0 overflows * 0 late commands * 0 timeouts usrp, comm.sdrureceiver, x310 MATLAB Answers — New Questions
Why are Name‑Value arguments not visible at function entry breakpoints in MATLAB R2025a?
I am using argument validation in a function that has multiple inputs including Name-Value pair arguments. When I set a breakpoint at the beginning of this function, only the first argument appears in the MATLAB R2025a Workspace immediately. The rest do not appear until after the arguments block finishes running. However, if I remove the Name-Value arguments, all of the values appear immediately.
Why does this occur? Is there a workaround?I am using argument validation in a function that has multiple inputs including Name-Value pair arguments. When I set a breakpoint at the beginning of this function, only the first argument appears in the MATLAB R2025a Workspace immediately. The rest do not appear until after the arguments block finishes running. However, if I remove the Name-Value arguments, all of the values appear immediately.
Why does this occur? Is there a workaround? I am using argument validation in a function that has multiple inputs including Name-Value pair arguments. When I set a breakpoint at the beginning of this function, only the first argument appears in the MATLAB R2025a Workspace immediately. The rest do not appear until after the arguments block finishes running. However, if I remove the Name-Value arguments, all of the values appear immediately.
Why does this occur? Is there a workaround? namevalue, arguments, validation, breakpoint, workspace MATLAB Answers — New Questions
Error converting python DataFrame to Table
I have used the following commands to load in a python .pkl file.
fid = py.open("data.pkl");
data = py.pickle.load(fid);
T = table(data);
This loads a python DataFrame object. Newer versions of MATLAB have the ability to convert this object to a table using the table command, which I tried but encountered the below error:
Error using py.pandas.DataFrame/table
Dimensions of the key and value must be the same, or the value must be scalar.
What does this error mean? I’m guessing it’s because the DataFrame object in the .pkl contains a couple nested fields. Most of the fields are simply 1xN numeric vectors, but a couple are 1xN objects which then have their own fields.
How can I convert this DataFrame object to something usable in MATLAB? I was given this datafile and did not generate it, and I am much more proficient in MATLAB than python, so I would rather solve this within MATLAB rather than having to create a python script or change how the file is created.I have used the following commands to load in a python .pkl file.
fid = py.open("data.pkl");
data = py.pickle.load(fid);
T = table(data);
This loads a python DataFrame object. Newer versions of MATLAB have the ability to convert this object to a table using the table command, which I tried but encountered the below error:
Error using py.pandas.DataFrame/table
Dimensions of the key and value must be the same, or the value must be scalar.
What does this error mean? I’m guessing it’s because the DataFrame object in the .pkl contains a couple nested fields. Most of the fields are simply 1xN numeric vectors, but a couple are 1xN objects which then have their own fields.
How can I convert this DataFrame object to something usable in MATLAB? I was given this datafile and did not generate it, and I am much more proficient in MATLAB than python, so I would rather solve this within MATLAB rather than having to create a python script or change how the file is created. I have used the following commands to load in a python .pkl file.
fid = py.open("data.pkl");
data = py.pickle.load(fid);
T = table(data);
This loads a python DataFrame object. Newer versions of MATLAB have the ability to convert this object to a table using the table command, which I tried but encountered the below error:
Error using py.pandas.DataFrame/table
Dimensions of the key and value must be the same, or the value must be scalar.
What does this error mean? I’m guessing it’s because the DataFrame object in the .pkl contains a couple nested fields. Most of the fields are simply 1xN numeric vectors, but a couple are 1xN objects which then have their own fields.
How can I convert this DataFrame object to something usable in MATLAB? I was given this datafile and did not generate it, and I am much more proficient in MATLAB than python, so I would rather solve this within MATLAB rather than having to create a python script or change how the file is created. python, table, dataframe MATLAB Answers — New Questions
How to add a header to a printed or published PDF from a MATLAB script in MATLAB R2025a?
I am printing a MATLAB script to PDF in MATLAB R2025a, but the header with the timestamp is missing. This header was included automatically in MATLAB R2024b. How can I add the header back in R2025a?I am printing a MATLAB script to PDF in MATLAB R2025a, but the header with the timestamp is missing. This header was included automatically in MATLAB R2024b. How can I add the header back in R2025a? I am printing a MATLAB script to PDF in MATLAB R2025a, but the header with the timestamp is missing. This header was included automatically in MATLAB R2024b. How can I add the header back in R2025a? header, print, matlab, editor, pdf, date, filename MATLAB Answers — New Questions
How to put a title on a colorbar?
I have a 3D surface surf(X,Y,Z) viewed from view(0,90) with a colorbar which I want to put a title on. The help instructions talk about an lcolorbar, TitleString and ZlabelString but there’s no example and I’m lost.
[X Y]=meshgrid(0:100,0:100);
Z=Y;
surf(X,Y,Z);
view(0,90);
hcb=colorbar;
?????? what next to put a title on the colorbar please ?????
Maybe something like set(get(hcb,’Title’),’cb title’) but I wouldn’t be asking if that worked …
Thanks.I have a 3D surface surf(X,Y,Z) viewed from view(0,90) with a colorbar which I want to put a title on. The help instructions talk about an lcolorbar, TitleString and ZlabelString but there’s no example and I’m lost.
[X Y]=meshgrid(0:100,0:100);
Z=Y;
surf(X,Y,Z);
view(0,90);
hcb=colorbar;
?????? what next to put a title on the colorbar please ?????
Maybe something like set(get(hcb,’Title’),’cb title’) but I wouldn’t be asking if that worked …
Thanks. I have a 3D surface surf(X,Y,Z) viewed from view(0,90) with a colorbar which I want to put a title on. The help instructions talk about an lcolorbar, TitleString and ZlabelString but there’s no example and I’m lost.
[X Y]=meshgrid(0:100,0:100);
Z=Y;
surf(X,Y,Z);
view(0,90);
hcb=colorbar;
?????? what next to put a title on the colorbar please ?????
Maybe something like set(get(hcb,’Title’),’cb title’) but I wouldn’t be asking if that worked …
Thanks. colorbar title surf titlestring MATLAB Answers — New Questions
UAV Toolbox Support Package for PX4 Autopilots — SITL plant simulation running much slower after recent windows update
I’ve been developing a custom controller using this toolbox, and everything has been working well after following the examples provided in the documentation.
However, after this last Tuesday, April 14th 2026, I attempted to monitor and tune my controller, and it threw an error saying the build failed and I need to go through the toolbox setup again (this is the first time I’ve gotten this error). I did this, and that is when problems developed. When using a simulink plant simulation for the PX4 SITL Host, the plant can no longer run in real time. It runs at about a quarter of the speed. I booted up the PX4 monitor and tune with plant example, and even that example is now running slowly too! Is it possible the recent security update affected TCP communication between Windows and the WSL network adapter?
Also, I am on R2025a.I’ve been developing a custom controller using this toolbox, and everything has been working well after following the examples provided in the documentation.
However, after this last Tuesday, April 14th 2026, I attempted to monitor and tune my controller, and it threw an error saying the build failed and I need to go through the toolbox setup again (this is the first time I’ve gotten this error). I did this, and that is when problems developed. When using a simulink plant simulation for the PX4 SITL Host, the plant can no longer run in real time. It runs at about a quarter of the speed. I booted up the PX4 monitor and tune with plant example, and even that example is now running slowly too! Is it possible the recent security update affected TCP communication between Windows and the WSL network adapter?
Also, I am on R2025a. I’ve been developing a custom controller using this toolbox, and everything has been working well after following the examples provided in the documentation.
However, after this last Tuesday, April 14th 2026, I attempted to monitor and tune my controller, and it threw an error saying the build failed and I need to go through the toolbox setup again (this is the first time I’ve gotten this error). I did this, and that is when problems developed. When using a simulink plant simulation for the PX4 SITL Host, the plant can no longer run in real time. It runs at about a quarter of the speed. I booted up the PX4 monitor and tune with plant example, and even that example is now running slowly too! Is it possible the recent security update affected TCP communication between Windows and the WSL network adapter?
Also, I am on R2025a. px4, uav toolbox support package, monitor and tune, simulink, plant MATLAB Answers — New Questions
I want to install Matlab on my desktop with connection from Network license server . Steps required
I want to install Matlab on my desktop with connection from Network license server . Steps requiredI want to install Matlab on my desktop with connection from Network license server . Steps required I want to install Matlab on my desktop with connection from Network license server . Steps required client installation MATLAB Answers — New Questions
Evaluate Noise and vibration of an EV motor (PMSM)
I want to find out the Noise and vibration of an EV motor PMSM by given few input data and getting results. So what is the process in the matlab/simulink to get the resultsI want to find out the Noise and vibration of an EV motor PMSM by given few input data and getting results. So what is the process in the matlab/simulink to get the results I want to find out the Noise and vibration of an EV motor PMSM by given few input data and getting results. So what is the process in the matlab/simulink to get the results nvh of an ev motor MATLAB Answers — New Questions
Stateflow transition does not work when using output bus field
Hello together,
I am facing a strange behaviour of my Simulink model. That model is comprised of a Simscape subsystem and a Stateflow subsystem. The latter is used to controll the operation mode of the Simscape model.
For a clear data transfer I implemented several data buses as Stateflow inputs and outputs. For that, I created the necessary Simulink Bus Objects and it works fine so far. But when I want to use one field of the Getoperationdata bus to describe the transition condition, the transition is not exceeded despite the condition is true (as shown in the figure below). The state Empty_Pump_Chamber remains active but should switch to Empty_Complete.
The Getoperationdata bus is implemented as an output bus. When defining a transition condition with a variable from another input bus, the model succeeds. Very strange. Even when I define a local variable, set this variable equal to Getoperationaldata.emptyComplete2 and use this new variable to state the transition condition, the model succeeds. Very strange! What is wrong?
Kind Regards!Hello together,
I am facing a strange behaviour of my Simulink model. That model is comprised of a Simscape subsystem and a Stateflow subsystem. The latter is used to controll the operation mode of the Simscape model.
For a clear data transfer I implemented several data buses as Stateflow inputs and outputs. For that, I created the necessary Simulink Bus Objects and it works fine so far. But when I want to use one field of the Getoperationdata bus to describe the transition condition, the transition is not exceeded despite the condition is true (as shown in the figure below). The state Empty_Pump_Chamber remains active but should switch to Empty_Complete.
The Getoperationdata bus is implemented as an output bus. When defining a transition condition with a variable from another input bus, the model succeeds. Very strange. Even when I define a local variable, set this variable equal to Getoperationaldata.emptyComplete2 and use this new variable to state the transition condition, the model succeeds. Very strange! What is wrong?
Kind Regards! Hello together,
I am facing a strange behaviour of my Simulink model. That model is comprised of a Simscape subsystem and a Stateflow subsystem. The latter is used to controll the operation mode of the Simscape model.
For a clear data transfer I implemented several data buses as Stateflow inputs and outputs. For that, I created the necessary Simulink Bus Objects and it works fine so far. But when I want to use one field of the Getoperationdata bus to describe the transition condition, the transition is not exceeded despite the condition is true (as shown in the figure below). The state Empty_Pump_Chamber remains active but should switch to Empty_Complete.
The Getoperationdata bus is implemented as an output bus. When defining a transition condition with a variable from another input bus, the model succeeds. Very strange. Even when I define a local variable, set this variable equal to Getoperationaldata.emptyComplete2 and use this new variable to state the transition condition, the model succeeds. Very strange! What is wrong?
Kind Regards! simulink bus object, transition MATLAB Answers — New Questions
Only version 2026a appears available for download as a trial. I want version 2025b
Only version 2026a appears available for download as a trial.
I want version 2025b, but it does not appear as an option at https://www.mathworks.com/downloads/web_downloads/13799194.Only version 2026a appears available for download as a trial.
I want version 2025b, but it does not appear as an option at https://www.mathworks.com/downloads/web_downloads/13799194. Only version 2026a appears available for download as a trial.
I want version 2025b, but it does not appear as an option at https://www.mathworks.com/downloads/web_downloads/13799194. r2025a MATLAB Answers — New Questions
Why the figure is not apearing after using plot(x) command?
Hi,
after new instalation of MATLAB 2025b my program does not use function plot properly.
After command "plot(x)" MATLAB opens new window "Figures" as usual but there is no figure.
After this line program continues execution.
I could not find the explanation jet.
Thanks!Hi,
after new instalation of MATLAB 2025b my program does not use function plot properly.
After command "plot(x)" MATLAB opens new window "Figures" as usual but there is no figure.
After this line program continues execution.
I could not find the explanation jet.
Thanks! Hi,
after new instalation of MATLAB 2025b my program does not use function plot properly.
After command "plot(x)" MATLAB opens new window "Figures" as usual but there is no figure.
After this line program continues execution.
I could not find the explanation jet.
Thanks! plot, figures MATLAB Answers — New Questions
I can’t able to see the orange, gray, red or green checks. Instead I can see only the code metrics.
I’m facing the issue i.e., I’m running the polyspace code prover throught the commend prompt. I used all the configuration in the option.txt file. Through that option.txt file i’m start compling by using this cmd ("C:Program FilesPOLYSPACER2023apolyspacebinpolyspace-code-prover" ^ -options-file Options.txt ^ -scheduler CHE6-SV00106 ^ -results-dir "C:UsersaallimutDocumentsSWEET500cb1146_vcore_main_devResult"). Compliation is done sucessfully and the code is pushed to the server. After successful complition of run I Checked the result, It’s only showing the code metrix, not showing any checks in the dashboard.I’m facing the issue i.e., I’m running the polyspace code prover throught the commend prompt. I used all the configuration in the option.txt file. Through that option.txt file i’m start compling by using this cmd ("C:Program FilesPOLYSPACER2023apolyspacebinpolyspace-code-prover" ^ -options-file Options.txt ^ -scheduler CHE6-SV00106 ^ -results-dir "C:UsersaallimutDocumentsSWEET500cb1146_vcore_main_devResult"). Compliation is done sucessfully and the code is pushed to the server. After successful complition of run I Checked the result, It’s only showing the code metrix, not showing any checks in the dashboard. I’m facing the issue i.e., I’m running the polyspace code prover throught the commend prompt. I used all the configuration in the option.txt file. Through that option.txt file i’m start compling by using this cmd ("C:Program FilesPOLYSPACER2023apolyspacebinpolyspace-code-prover" ^ -options-file Options.txt ^ -scheduler CHE6-SV00106 ^ -results-dir "C:UsersaallimutDocumentsSWEET500cb1146_vcore_main_devResult"). Compliation is done sucessfully and the code is pushed to the server. After successful complition of run I Checked the result, It’s only showing the code metrix, not showing any checks in the dashboard. no checks found MATLAB Answers — New Questions
Identifying bright spots in RGB image
I have hundreds of RGB images (one of the image is attached). For reference these are interference images and the RGB color values correspond to certain film thickness between a semi reflective glass surface and a steel surface. I apply electric potential across the surface and observed electric discharges which show as bright spots on the image (highlighted in red circle in attached image).
I want to write a script in MATLAB (2023a) that goes through the images, identify these bright spots stores there location in the XY cordinate system. The end goal is to show spatial distribution of the electric discharges.I have hundreds of RGB images (one of the image is attached). For reference these are interference images and the RGB color values correspond to certain film thickness between a semi reflective glass surface and a steel surface. I apply electric potential across the surface and observed electric discharges which show as bright spots on the image (highlighted in red circle in attached image).
I want to write a script in MATLAB (2023a) that goes through the images, identify these bright spots stores there location in the XY cordinate system. The end goal is to show spatial distribution of the electric discharges. I have hundreds of RGB images (one of the image is attached). For reference these are interference images and the RGB color values correspond to certain film thickness between a semi reflective glass surface and a steel surface. I apply electric potential across the surface and observed electric discharges which show as bright spots on the image (highlighted in red circle in attached image).
I want to write a script in MATLAB (2023a) that goes through the images, identify these bright spots stores there location in the XY cordinate system. The end goal is to show spatial distribution of the electric discharges. image analysis, image processing MATLAB Answers — New Questions









