Category: Matlab
Category Archives: Matlab
how to model a fire alarm system on simulink
KIndly advise as to how I can model and simulate a fire alarm system on simulink. So if you can suggest any crediable and reliable learning resources that would be best.KIndly advise as to how I can model and simulate a fire alarm system on simulink. So if you can suggest any crediable and reliable learning resources that would be best. KIndly advise as to how I can model and simulate a fire alarm system on simulink. So if you can suggest any crediable and reliable learning resources that would be best. fire alarms, simulink MATLAB Answers — New Questions
Sensor Fusion and Tracking Toolbox
I have installed Sensor Fusion and Tracking toolbox for my MATLAB R2019a but when i try to open example using this command:
openExample(‘shared_fusion_arduinoio/EstimateOrientationUsingInertialSensorFusionAndMPU9250Example’)
I get this message:
Error using exampleUtils.componentExamplesDir (line 13)
Invalid argument "shared_fusion_arduinoio".
Error in findExample (line 18)
componentExamplesDir =
exampleUtils.componentExamplesDir(component);
Error in openExample (line 24)
metadata = findExample(id);
Actualy I want to use HelperOrientationViewer command to view the 3D pose of my IMU sensor which is possible via this example because when i try to do that it just gives error:
Undefined function or variable ‘HelperOrientationViewer’.
Error in matlab_mpu9250 (line 72)
viewer = HelperOrientationViewer(‘Title’,{‘AHRS Filter’});
Please do help me i really need Viewer for proper visualization of my robot’s orientation.I have installed Sensor Fusion and Tracking toolbox for my MATLAB R2019a but when i try to open example using this command:
openExample(‘shared_fusion_arduinoio/EstimateOrientationUsingInertialSensorFusionAndMPU9250Example’)
I get this message:
Error using exampleUtils.componentExamplesDir (line 13)
Invalid argument "shared_fusion_arduinoio".
Error in findExample (line 18)
componentExamplesDir =
exampleUtils.componentExamplesDir(component);
Error in openExample (line 24)
metadata = findExample(id);
Actualy I want to use HelperOrientationViewer command to view the 3D pose of my IMU sensor which is possible via this example because when i try to do that it just gives error:
Undefined function or variable ‘HelperOrientationViewer’.
Error in matlab_mpu9250 (line 72)
viewer = HelperOrientationViewer(‘Title’,{‘AHRS Filter’});
Please do help me i really need Viewer for proper visualization of my robot’s orientation. I have installed Sensor Fusion and Tracking toolbox for my MATLAB R2019a but when i try to open example using this command:
openExample(‘shared_fusion_arduinoio/EstimateOrientationUsingInertialSensorFusionAndMPU9250Example’)
I get this message:
Error using exampleUtils.componentExamplesDir (line 13)
Invalid argument "shared_fusion_arduinoio".
Error in findExample (line 18)
componentExamplesDir =
exampleUtils.componentExamplesDir(component);
Error in openExample (line 24)
metadata = findExample(id);
Actualy I want to use HelperOrientationViewer command to view the 3D pose of my IMU sensor which is possible via this example because when i try to do that it just gives error:
Undefined function or variable ‘HelperOrientationViewer’.
Error in matlab_mpu9250 (line 72)
viewer = HelperOrientationViewer(‘Title’,{‘AHRS Filter’});
Please do help me i really need Viewer for proper visualization of my robot’s orientation. mpu9250, sensor fusion, toolbox, error opening example, helper orientation viewer, matlab2019a, imu MATLAB Answers — New Questions
How to read shape file in matlab?
I am using following matlab code to read shape file. I am attaching the shape file also as zip file.
% pickup the shape files
d = uigetdir(pwd, ‘Select a folder’);
shapefiles = dir(fullfile(d, ‘*.shp’));
for n = 1:length(shapefiles)
shapefile = shapefiles(n);
disp(shapefile.name);
S = shaperead(shapefile.name);
polygon = polyshape([S.X], [S.Y]);
% Create a logical mask
logical_mask = inpolygon(lon, lat, polygon.Vertices(:, 1), polygon.Vertices(:, 2));
end
This is giving the following errors;
>> testrnAchi Khurd.shp
Error using openShapeFiles>checkSHP (line 82)
Unable to open file ‘Achi Khurd.shp’. Check the path and filename or file permissions.
Error in openShapeFiles (line 19)
[basename, ext] = checkSHP(basename,shapeExtensionProvided);
Error in shaperead (line 212)
= openShapeFiles(filename,’shaperead’);
Error
in test (line 9)
S = shaperead(shapefile.name);
>>
Please suggest me how to fix it? I would be highly obliged for kind help.
DaveI am using following matlab code to read shape file. I am attaching the shape file also as zip file.
% pickup the shape files
d = uigetdir(pwd, ‘Select a folder’);
shapefiles = dir(fullfile(d, ‘*.shp’));
for n = 1:length(shapefiles)
shapefile = shapefiles(n);
disp(shapefile.name);
S = shaperead(shapefile.name);
polygon = polyshape([S.X], [S.Y]);
% Create a logical mask
logical_mask = inpolygon(lon, lat, polygon.Vertices(:, 1), polygon.Vertices(:, 2));
end
This is giving the following errors;
>> testrnAchi Khurd.shp
Error using openShapeFiles>checkSHP (line 82)
Unable to open file ‘Achi Khurd.shp’. Check the path and filename or file permissions.
Error in openShapeFiles (line 19)
[basename, ext] = checkSHP(basename,shapeExtensionProvided);
Error in shaperead (line 212)
= openShapeFiles(filename,’shaperead’);
Error
in test (line 9)
S = shaperead(shapefile.name);
>>
Please suggest me how to fix it? I would be highly obliged for kind help.
Dave I am using following matlab code to read shape file. I am attaching the shape file also as zip file.
% pickup the shape files
d = uigetdir(pwd, ‘Select a folder’);
shapefiles = dir(fullfile(d, ‘*.shp’));
for n = 1:length(shapefiles)
shapefile = shapefiles(n);
disp(shapefile.name);
S = shaperead(shapefile.name);
polygon = polyshape([S.X], [S.Y]);
% Create a logical mask
logical_mask = inpolygon(lon, lat, polygon.Vertices(:, 1), polygon.Vertices(:, 2));
end
This is giving the following errors;
>> testrnAchi Khurd.shp
Error using openShapeFiles>checkSHP (line 82)
Unable to open file ‘Achi Khurd.shp’. Check the path and filename or file permissions.
Error in openShapeFiles (line 19)
[basename, ext] = checkSHP(basename,shapeExtensionProvided);
Error in shaperead (line 212)
= openShapeFiles(filename,’shaperead’);
Error
in test (line 9)
S = shaperead(shapefile.name);
>>
Please suggest me how to fix it? I would be highly obliged for kind help.
Dave how to read shape file in matlab? MATLAB Answers — New Questions
MATLAB code of intersection
Hello, i intersect two sets of lines from two different origins at a distance of 10 cm from 0 to 90 degrees with an angle difference of two degrees. A straight line is obtained from the intersection of lines of the same degree. From the collision of lines, twice the degree of curvature is obtained. I need a MATLAB code to draw this straight line and curves.Hello, i intersect two sets of lines from two different origins at a distance of 10 cm from 0 to 90 degrees with an angle difference of two degrees. A straight line is obtained from the intersection of lines of the same degree. From the collision of lines, twice the degree of curvature is obtained. I need a MATLAB code to draw this straight line and curves. Hello, i intersect two sets of lines from two different origins at a distance of 10 cm from 0 to 90 degrees with an angle difference of two degrees. A straight line is obtained from the intersection of lines of the same degree. From the collision of lines, twice the degree of curvature is obtained. I need a MATLAB code to draw this straight line and curves. matlab, line, intersection MATLAB Answers — New Questions
Similar image grouping in dataset
I want to group the images in a dataset according to the similarity ratio. When grouping, it can be based on certain objects(cars,trees,faces).After the images are determined, filing or a different dataset can be created. How can I find the similarity and how can i grouping?
Thank you.I want to group the images in a dataset according to the similarity ratio. When grouping, it can be based on certain objects(cars,trees,faces).After the images are determined, filing or a different dataset can be created. How can I find the similarity and how can i grouping?
Thank you. I want to group the images in a dataset according to the similarity ratio. When grouping, it can be based on certain objects(cars,trees,faces).After the images are determined, filing or a different dataset can be created. How can I find the similarity and how can i grouping?
Thank you. image, image analysis, image segmentation, image processing MATLAB Answers — New Questions
Hi, i try to solve equation c in terms of other variables, and its appear the messages and the answers is not as expected. Is supposed to be beta/p^(1/sigma)? is it?
Post Content Post Content solving equations MATLAB Answers — New Questions
Powergui FFT Analysis Tool doesn’t work!
When I use the Powergui FFT Analysis Tool (in the matlab 2019a), I find it can’work. In the module of "Available signals","Name" and "Input" are always "Empty", though I have selected “Log data to workspace” and "structure with time".Are there any other parameters to set?When I use the Powergui FFT Analysis Tool (in the matlab 2019a), I find it can’work. In the module of "Available signals","Name" and "Input" are always "Empty", though I have selected “Log data to workspace” and "structure with time".Are there any other parameters to set? When I use the Powergui FFT Analysis Tool (in the matlab 2019a), I find it can’work. In the module of "Available signals","Name" and "Input" are always "Empty", though I have selected “Log data to workspace” and "structure with time".Are there any other parameters to set? powergui, fft MATLAB Answers — New Questions
Importing Mf4 file
Hello Dear Matlab community,
I need to import the mf4 files using mdf. it works fine for .dat file and .mdf files with mdfimport, but when it comes to .mf4 it asks to add the one of the toolbox Powertrain Blockset or Vehicle Network Toolbox , is it the only way to import the file , i mean i do really need one of those toolbox ?
Thnaks in advanceHello Dear Matlab community,
I need to import the mf4 files using mdf. it works fine for .dat file and .mdf files with mdfimport, but when it comes to .mf4 it asks to add the one of the toolbox Powertrain Blockset or Vehicle Network Toolbox , is it the only way to import the file , i mean i do really need one of those toolbox ?
Thnaks in advance Hello Dear Matlab community,
I need to import the mf4 files using mdf. it works fine for .dat file and .mdf files with mdfimport, but when it comes to .mf4 it asks to add the one of the toolbox Powertrain Blockset or Vehicle Network Toolbox , is it the only way to import the file , i mean i do really need one of those toolbox ?
Thnaks in advance import mdf MATLAB Answers — New Questions
Partitioning data for Time Series TCN model Training, Validation, and Testing
Hello there, I am trying to build a TCN model to predict a continuous variable. I have time series data in which I am using 3 input features (accelrometer measuments in x,y,z directions) to estimate/predict a continuous variable. I have acceleromter data from 10 different trials stored in a 10×1 cell and each cell has the three accelerometer measurments over time stored in a 500×3 table for that trial. The target continous varable I am trying to predict is simialrly stored in a 10×1 cell array with each cell contaning a the a 500×1 table which is the true value of the predicted variable over time named "Taget". If I am trying to build a TCN model with this data what is the best way to partition the data for training, testing (10%), and validation (10%)? I think I need to use the tspartition function but am not sure how to use it for this type of data. Do I need to combine the data from all 10 trials into one large table and then partition? Or should I partition each trial seprately, train the model on a singluar trial, and then retrain the model on the next trial and so on. Any help would be greatly appreciated!Hello there, I am trying to build a TCN model to predict a continuous variable. I have time series data in which I am using 3 input features (accelrometer measuments in x,y,z directions) to estimate/predict a continuous variable. I have acceleromter data from 10 different trials stored in a 10×1 cell and each cell has the three accelerometer measurments over time stored in a 500×3 table for that trial. The target continous varable I am trying to predict is simialrly stored in a 10×1 cell array with each cell contaning a the a 500×1 table which is the true value of the predicted variable over time named "Taget". If I am trying to build a TCN model with this data what is the best way to partition the data for training, testing (10%), and validation (10%)? I think I need to use the tspartition function but am not sure how to use it for this type of data. Do I need to combine the data from all 10 trials into one large table and then partition? Or should I partition each trial seprately, train the model on a singluar trial, and then retrain the model on the next trial and so on. Any help would be greatly appreciated! Hello there, I am trying to build a TCN model to predict a continuous variable. I have time series data in which I am using 3 input features (accelrometer measuments in x,y,z directions) to estimate/predict a continuous variable. I have acceleromter data from 10 different trials stored in a 10×1 cell and each cell has the three accelerometer measurments over time stored in a 500×3 table for that trial. The target continous varable I am trying to predict is simialrly stored in a 10×1 cell array with each cell contaning a the a 500×1 table which is the true value of the predicted variable over time named "Taget". If I am trying to build a TCN model with this data what is the best way to partition the data for training, testing (10%), and validation (10%)? I think I need to use the tspartition function but am not sure how to use it for this type of data. Do I need to combine the data from all 10 trials into one large table and then partition? Or should I partition each trial seprately, train the model on a singluar trial, and then retrain the model on the next trial and so on. Any help would be greatly appreciated! model, machine learning MATLAB Answers — New Questions
selected workspace variables in Matlab
Is it possible to only display a selected group of variables in the workspace window instead of all of them?Is it possible to only display a selected group of variables in the workspace window instead of all of them? Is it possible to only display a selected group of variables in the workspace window instead of all of them? matlab selected workspace variables MATLAB Answers — New Questions
Replace NaN with Blanks
Hi guys I have a double matrix as shown in the attached picture that I am trying to replace all NaN values with Empty spaces so that the over all matrix dimension will be maintained. However, when I looked through the function and suggested solutions non of them is actully working what possible code can be used.
Thanks in advanceHi guys I have a double matrix as shown in the attached picture that I am trying to replace all NaN values with Empty spaces so that the over all matrix dimension will be maintained. However, when I looked through the function and suggested solutions non of them is actully working what possible code can be used.
Thanks in advance Hi guys I have a double matrix as shown in the attached picture that I am trying to replace all NaN values with Empty spaces so that the over all matrix dimension will be maintained. However, when I looked through the function and suggested solutions non of them is actully working what possible code can be used.
Thanks in advance nan, blank, empty, matrix MATLAB Answers — New Questions
Why are the descriptive names of my boxchart categories not visible in my figure?
Hi all, I am trying to visualise ply thicknesses (in multiple composite samples) using boxchart(). I manage to show the boxes according to the ply numbers. However, I would like to mention the fibre orientation with the ply numbers as well. The (adapted, for readability) code I used so far is shown below. I also included the result I obtained.
My problem is that the y-axis do not show both the number and the orientation of the plies. I tried to follow the "Create Multiple Box Charts Using Positional Grouping Variable" example in the boxchart documentation, because this example shows the replacement of numbered axis-ticklabels to a descriptive label (just like I want my axis to be). It tells me to use categorical() to "replace" the plain ply numbers, after which I need to use boxchart. Although I think I applied this example correctly to my case and all intermediate steps look like they were executed as desired, the figure does not turn out as intended. Why are the descriptive names on the y-axis not visible in the figure?
table = array2table([nr t]; % A table containing the ply numbers (pnr) and their corresponding thicknesses (t). This outputs a table with many rows (the amount of samples with n plies) by 2 columns (pnr and t)
for i = 1:nplies
p_ors_str = string(sprintf(‘%02i: %i%c’,nply(i),layup_weld(i),char(0176)))); % Describing the ply number with the corresponding orientation
end % Results in a nplies*1 string containing element similar to "01: 45°".
p_ors_cat = categorical(table.nr,1:nplies,p_ors_str); % Converting the ply numbers to a descriptive string in a categorical array
figure(1), clf(1), hold on
subplot(2,1,1), hold on % This method corresponds to the "boxchart(earthquakes.Month,earthquakes.EarthquakeMagnitude)"-command in the example
boxchart(table.pnr,table.t,’Orientation’,’Horizontal’) % The boxes visualise the several measurements for every ply, showing ply numbers
ylabel(‘Ply number’)
subplot(2,1,2), hold on % This method corresponds to the "boxchart(namedMonths,earthquakes.EarthquakeMagnitude)"-command in the example
boxchart(p_ors_str,table.t,’Orientation’,’Horizontal’) % The boxes should visualise the same as before, but describing the ply number with their orientation
ylabel(‘Ply number and orientation’)Hi all, I am trying to visualise ply thicknesses (in multiple composite samples) using boxchart(). I manage to show the boxes according to the ply numbers. However, I would like to mention the fibre orientation with the ply numbers as well. The (adapted, for readability) code I used so far is shown below. I also included the result I obtained.
My problem is that the y-axis do not show both the number and the orientation of the plies. I tried to follow the "Create Multiple Box Charts Using Positional Grouping Variable" example in the boxchart documentation, because this example shows the replacement of numbered axis-ticklabels to a descriptive label (just like I want my axis to be). It tells me to use categorical() to "replace" the plain ply numbers, after which I need to use boxchart. Although I think I applied this example correctly to my case and all intermediate steps look like they were executed as desired, the figure does not turn out as intended. Why are the descriptive names on the y-axis not visible in the figure?
table = array2table([nr t]; % A table containing the ply numbers (pnr) and their corresponding thicknesses (t). This outputs a table with many rows (the amount of samples with n plies) by 2 columns (pnr and t)
for i = 1:nplies
p_ors_str = string(sprintf(‘%02i: %i%c’,nply(i),layup_weld(i),char(0176)))); % Describing the ply number with the corresponding orientation
end % Results in a nplies*1 string containing element similar to "01: 45°".
p_ors_cat = categorical(table.nr,1:nplies,p_ors_str); % Converting the ply numbers to a descriptive string in a categorical array
figure(1), clf(1), hold on
subplot(2,1,1), hold on % This method corresponds to the "boxchart(earthquakes.Month,earthquakes.EarthquakeMagnitude)"-command in the example
boxchart(table.pnr,table.t,’Orientation’,’Horizontal’) % The boxes visualise the several measurements for every ply, showing ply numbers
ylabel(‘Ply number’)
subplot(2,1,2), hold on % This method corresponds to the "boxchart(namedMonths,earthquakes.EarthquakeMagnitude)"-command in the example
boxchart(p_ors_str,table.t,’Orientation’,’Horizontal’) % The boxes should visualise the same as before, but describing the ply number with their orientation
ylabel(‘Ply number and orientation’) Hi all, I am trying to visualise ply thicknesses (in multiple composite samples) using boxchart(). I manage to show the boxes according to the ply numbers. However, I would like to mention the fibre orientation with the ply numbers as well. The (adapted, for readability) code I used so far is shown below. I also included the result I obtained.
My problem is that the y-axis do not show both the number and the orientation of the plies. I tried to follow the "Create Multiple Box Charts Using Positional Grouping Variable" example in the boxchart documentation, because this example shows the replacement of numbered axis-ticklabels to a descriptive label (just like I want my axis to be). It tells me to use categorical() to "replace" the plain ply numbers, after which I need to use boxchart. Although I think I applied this example correctly to my case and all intermediate steps look like they were executed as desired, the figure does not turn out as intended. Why are the descriptive names on the y-axis not visible in the figure?
table = array2table([nr t]; % A table containing the ply numbers (pnr) and their corresponding thicknesses (t). This outputs a table with many rows (the amount of samples with n plies) by 2 columns (pnr and t)
for i = 1:nplies
p_ors_str = string(sprintf(‘%02i: %i%c’,nply(i),layup_weld(i),char(0176)))); % Describing the ply number with the corresponding orientation
end % Results in a nplies*1 string containing element similar to "01: 45°".
p_ors_cat = categorical(table.nr,1:nplies,p_ors_str); % Converting the ply numbers to a descriptive string in a categorical array
figure(1), clf(1), hold on
subplot(2,1,1), hold on % This method corresponds to the "boxchart(earthquakes.Month,earthquakes.EarthquakeMagnitude)"-command in the example
boxchart(table.pnr,table.t,’Orientation’,’Horizontal’) % The boxes visualise the several measurements for every ply, showing ply numbers
ylabel(‘Ply number’)
subplot(2,1,2), hold on % This method corresponds to the "boxchart(namedMonths,earthquakes.EarthquakeMagnitude)"-command in the example
boxchart(p_ors_str,table.t,’Orientation’,’Horizontal’) % The boxes should visualise the same as before, but describing the ply number with their orientation
ylabel(‘Ply number and orientation’) boxchart, plotting, boxplot, yticklabels, ticklabels, xticklabels, composites MATLAB Answers — New Questions
Temperature dependent thermal diffusivity using PDE Toolbox
Hello,
This is my first implementation of a problem using the PDE Toolbox. My 3D time-dependent thermal model is the following : a sphere (radius equals to 1) with radiative flux on the outside surface, with cell at inital temperature . I would like to use a temperature dependent thermal diffusivity where . I have then an analytical expression for it given by : , which I know from documentation for my material.
The parameters used in my simulations are the following :
lambda = @(location,state) 0.46+0.95*exp(-2.3e-3*state.u); % (W/m/K) Thermal conductivity
rho=1000; % (kg/m**3) Density
cp=1000; % (J/kg/K) Specific heat
T0=2000; % (K) Initial temperature
T_out=300; % (K) outer space temperature
eps=1; % Emissivity
dt=20; % (s) time-step
day=3600*24;
tmax=2*day;
tlist = [0:dt:tmax]; % time list
I then implement my model using Matlab PDE Toolbox :
thermalModel = createpde(‘thermal’,’transient’);
gm = multisphere(1);
thermalModel.Geometry=gm;
generateMesh(thermalModel,’Hmax’,0.2,"GeometricOrder","quadratic");
thermalModel.StefanBoltzmannConstant = 5.670373E-8;
thermalProperties(thermalModel,’ThermalConductivity’,lambda,’MassDensity’,rho,’SpecificHeat’,cp);
% Initial Temperature
thermalIC(thermalModel,T0);
% Radiative Flux :
thermalBC(thermalModel,"Face",1,"Emissivity",@(region,state) eps,"AmbientTemperature",T_out, "Vectorized","on");
% Solver
thermalResults = solve(thermalModel,tlist);
Does anyone know whether the implementation is correct ?
Many thanks for any help you can give me !
Regards,
TomHello,
This is my first implementation of a problem using the PDE Toolbox. My 3D time-dependent thermal model is the following : a sphere (radius equals to 1) with radiative flux on the outside surface, with cell at inital temperature . I would like to use a temperature dependent thermal diffusivity where . I have then an analytical expression for it given by : , which I know from documentation for my material.
The parameters used in my simulations are the following :
lambda = @(location,state) 0.46+0.95*exp(-2.3e-3*state.u); % (W/m/K) Thermal conductivity
rho=1000; % (kg/m**3) Density
cp=1000; % (J/kg/K) Specific heat
T0=2000; % (K) Initial temperature
T_out=300; % (K) outer space temperature
eps=1; % Emissivity
dt=20; % (s) time-step
day=3600*24;
tmax=2*day;
tlist = [0:dt:tmax]; % time list
I then implement my model using Matlab PDE Toolbox :
thermalModel = createpde(‘thermal’,’transient’);
gm = multisphere(1);
thermalModel.Geometry=gm;
generateMesh(thermalModel,’Hmax’,0.2,"GeometricOrder","quadratic");
thermalModel.StefanBoltzmannConstant = 5.670373E-8;
thermalProperties(thermalModel,’ThermalConductivity’,lambda,’MassDensity’,rho,’SpecificHeat’,cp);
% Initial Temperature
thermalIC(thermalModel,T0);
% Radiative Flux :
thermalBC(thermalModel,"Face",1,"Emissivity",@(region,state) eps,"AmbientTemperature",T_out, "Vectorized","on");
% Solver
thermalResults = solve(thermalModel,tlist);
Does anyone know whether the implementation is correct ?
Many thanks for any help you can give me !
Regards,
Tom Hello,
This is my first implementation of a problem using the PDE Toolbox. My 3D time-dependent thermal model is the following : a sphere (radius equals to 1) with radiative flux on the outside surface, with cell at inital temperature . I would like to use a temperature dependent thermal diffusivity where . I have then an analytical expression for it given by : , which I know from documentation for my material.
The parameters used in my simulations are the following :
lambda = @(location,state) 0.46+0.95*exp(-2.3e-3*state.u); % (W/m/K) Thermal conductivity
rho=1000; % (kg/m**3) Density
cp=1000; % (J/kg/K) Specific heat
T0=2000; % (K) Initial temperature
T_out=300; % (K) outer space temperature
eps=1; % Emissivity
dt=20; % (s) time-step
day=3600*24;
tmax=2*day;
tlist = [0:dt:tmax]; % time list
I then implement my model using Matlab PDE Toolbox :
thermalModel = createpde(‘thermal’,’transient’);
gm = multisphere(1);
thermalModel.Geometry=gm;
generateMesh(thermalModel,’Hmax’,0.2,"GeometricOrder","quadratic");
thermalModel.StefanBoltzmannConstant = 5.670373E-8;
thermalProperties(thermalModel,’ThermalConductivity’,lambda,’MassDensity’,rho,’SpecificHeat’,cp);
% Initial Temperature
thermalIC(thermalModel,T0);
% Radiative Flux :
thermalBC(thermalModel,"Face",1,"Emissivity",@(region,state) eps,"AmbientTemperature",T_out, "Vectorized","on");
% Solver
thermalResults = solve(thermalModel,tlist);
Does anyone know whether the implementation is correct ?
Many thanks for any help you can give me !
Regards,
Tom pde, diffusivity, toolbox, thermal, temperature, dependent MATLAB Answers — New Questions
Hiding the drag points on a Matlab images.roi.Circle, and other ways of using ROIs as selection masks
Hello All,
TLDR at bottom
This question applies more broadly to the new Matlab images.roi objects, but I realized that the ROI’s are ideally set up to create selection bit-masks in an image. I can throw some arbitrary graphic into a figure, put an ROI below it, and use the ROI interface to determine when I mouse-over and click on that region. Depending on my needs I could also make my inset area draggable and stretchable depending on how I link in my ROI’s callbacks for movingROI and roiMoved. If I wanted to rebuild Myst in Matlab, this is how I would do it.
However, the sticky wicket is that you cannot as far as I can tell make an invisible ROI; the current format insists on drawing a border, and for some ROI objects it forces the appearence of drag points. Here is an example:
I = imread(‘cameraman.tif’);
imshow(I);
ax = gca;
circ = images.roi.Circle(ax,’Position’,[114 60],’Radius’,30);
Ok, so I have a nice circle ROI centered on the camerman’s head. I can make the center invisible via
set(circ,’FaceAlpha’,0)
However, both the border and the drag points are still visible: I cannot find a property or method to disable them!
Well, I can always set the circle to be invisible
set(circ,’visible’,’off’);
BUT this not only makes the circle visibly vanish, but also means that all of the interactions it came with are not accessible; I can only translate/etc the ROI programattically, not through the UI. Thus it makes a really poor selection mask.
I hoped that another option would be to limit us to translation:
set(circ,’InteractionsAllowed’,’translate’);
Thus, the drag points are no longer necessary…but they are still visible!
Ok, so I do know that it is possible to hide the drag markers, using
set(circ,’InteractionsAllowed’,’none’);
BUT, again this makes my ROI useless, as I cannot interact with it in any way.
I thought I had a genius moment, and added a listener that would only enable interactions when the ROI was selected:
addlistener(circ, ‘ROIClicked’, @(s,evtData) selectListener(s,evtData));
function selectListener(s,evtData)
selectedPart = evtData.SelectedPart
prevselected = evtData.PreviousSelected
if selectedPart && ~prevselected
set(circ,’InteractionsAllowed’,’Translation’);
else
set(circ,’InteractionsAllowed’,’none’);
end
Once again…failure. I cannot select an ROI with no interactions allowed; the istener is never called. I have to allow translations, stretching, or both.
This causes other potential issues, if I want to programattically draw an ROI and have some callback when selected but not allow moving the ROI, I have to lock the ROI in place using the movingROI callback rather than simply disabling the two movements; there should be a "no movement, but allow selection" setting, but I digress.
One kludge does let me at least get rid of the hideous drag buttons, but still leaves the outline (and is just plain dumb):
msk = images.roi.Freehand(ax,’Position’,circ.Vertices,’Waypoints’,false(size(circ.Vertices,1),1),’FaceAlpha’,0,’LineWidth’,.1);
delete(circ);
———————————————-
TLDR – I want to create an invisible but still interactable ROI using the images.roi toolbox. This requires hiding the outline and the drag points. I cannot do this and retain interactability. Is there a workaround?
Cheers,
-Dan
———————————————
P.S. I really dislike p-code. I understand the reason for it, but not being able to change simple properties and behaviors (such as making the drag points invisible) and not being able to figure out why is infuriating.Hello All,
TLDR at bottom
This question applies more broadly to the new Matlab images.roi objects, but I realized that the ROI’s are ideally set up to create selection bit-masks in an image. I can throw some arbitrary graphic into a figure, put an ROI below it, and use the ROI interface to determine when I mouse-over and click on that region. Depending on my needs I could also make my inset area draggable and stretchable depending on how I link in my ROI’s callbacks for movingROI and roiMoved. If I wanted to rebuild Myst in Matlab, this is how I would do it.
However, the sticky wicket is that you cannot as far as I can tell make an invisible ROI; the current format insists on drawing a border, and for some ROI objects it forces the appearence of drag points. Here is an example:
I = imread(‘cameraman.tif’);
imshow(I);
ax = gca;
circ = images.roi.Circle(ax,’Position’,[114 60],’Radius’,30);
Ok, so I have a nice circle ROI centered on the camerman’s head. I can make the center invisible via
set(circ,’FaceAlpha’,0)
However, both the border and the drag points are still visible: I cannot find a property or method to disable them!
Well, I can always set the circle to be invisible
set(circ,’visible’,’off’);
BUT this not only makes the circle visibly vanish, but also means that all of the interactions it came with are not accessible; I can only translate/etc the ROI programattically, not through the UI. Thus it makes a really poor selection mask.
I hoped that another option would be to limit us to translation:
set(circ,’InteractionsAllowed’,’translate’);
Thus, the drag points are no longer necessary…but they are still visible!
Ok, so I do know that it is possible to hide the drag markers, using
set(circ,’InteractionsAllowed’,’none’);
BUT, again this makes my ROI useless, as I cannot interact with it in any way.
I thought I had a genius moment, and added a listener that would only enable interactions when the ROI was selected:
addlistener(circ, ‘ROIClicked’, @(s,evtData) selectListener(s,evtData));
function selectListener(s,evtData)
selectedPart = evtData.SelectedPart
prevselected = evtData.PreviousSelected
if selectedPart && ~prevselected
set(circ,’InteractionsAllowed’,’Translation’);
else
set(circ,’InteractionsAllowed’,’none’);
end
Once again…failure. I cannot select an ROI with no interactions allowed; the istener is never called. I have to allow translations, stretching, or both.
This causes other potential issues, if I want to programattically draw an ROI and have some callback when selected but not allow moving the ROI, I have to lock the ROI in place using the movingROI callback rather than simply disabling the two movements; there should be a "no movement, but allow selection" setting, but I digress.
One kludge does let me at least get rid of the hideous drag buttons, but still leaves the outline (and is just plain dumb):
msk = images.roi.Freehand(ax,’Position’,circ.Vertices,’Waypoints’,false(size(circ.Vertices,1),1),’FaceAlpha’,0,’LineWidth’,.1);
delete(circ);
———————————————-
TLDR – I want to create an invisible but still interactable ROI using the images.roi toolbox. This requires hiding the outline and the drag points. I cannot do this and retain interactability. Is there a workaround?
Cheers,
-Dan
———————————————
P.S. I really dislike p-code. I understand the reason for it, but not being able to change simple properties and behaviors (such as making the drag points invisible) and not being able to figure out why is infuriating. Hello All,
TLDR at bottom
This question applies more broadly to the new Matlab images.roi objects, but I realized that the ROI’s are ideally set up to create selection bit-masks in an image. I can throw some arbitrary graphic into a figure, put an ROI below it, and use the ROI interface to determine when I mouse-over and click on that region. Depending on my needs I could also make my inset area draggable and stretchable depending on how I link in my ROI’s callbacks for movingROI and roiMoved. If I wanted to rebuild Myst in Matlab, this is how I would do it.
However, the sticky wicket is that you cannot as far as I can tell make an invisible ROI; the current format insists on drawing a border, and for some ROI objects it forces the appearence of drag points. Here is an example:
I = imread(‘cameraman.tif’);
imshow(I);
ax = gca;
circ = images.roi.Circle(ax,’Position’,[114 60],’Radius’,30);
Ok, so I have a nice circle ROI centered on the camerman’s head. I can make the center invisible via
set(circ,’FaceAlpha’,0)
However, both the border and the drag points are still visible: I cannot find a property or method to disable them!
Well, I can always set the circle to be invisible
set(circ,’visible’,’off’);
BUT this not only makes the circle visibly vanish, but also means that all of the interactions it came with are not accessible; I can only translate/etc the ROI programattically, not through the UI. Thus it makes a really poor selection mask.
I hoped that another option would be to limit us to translation:
set(circ,’InteractionsAllowed’,’translate’);
Thus, the drag points are no longer necessary…but they are still visible!
Ok, so I do know that it is possible to hide the drag markers, using
set(circ,’InteractionsAllowed’,’none’);
BUT, again this makes my ROI useless, as I cannot interact with it in any way.
I thought I had a genius moment, and added a listener that would only enable interactions when the ROI was selected:
addlistener(circ, ‘ROIClicked’, @(s,evtData) selectListener(s,evtData));
function selectListener(s,evtData)
selectedPart = evtData.SelectedPart
prevselected = evtData.PreviousSelected
if selectedPart && ~prevselected
set(circ,’InteractionsAllowed’,’Translation’);
else
set(circ,’InteractionsAllowed’,’none’);
end
Once again…failure. I cannot select an ROI with no interactions allowed; the istener is never called. I have to allow translations, stretching, or both.
This causes other potential issues, if I want to programattically draw an ROI and have some callback when selected but not allow moving the ROI, I have to lock the ROI in place using the movingROI callback rather than simply disabling the two movements; there should be a "no movement, but allow selection" setting, but I digress.
One kludge does let me at least get rid of the hideous drag buttons, but still leaves the outline (and is just plain dumb):
msk = images.roi.Freehand(ax,’Position’,circ.Vertices,’Waypoints’,false(size(circ.Vertices,1),1),’FaceAlpha’,0,’LineWidth’,.1);
delete(circ);
———————————————-
TLDR – I want to create an invisible but still interactable ROI using the images.roi toolbox. This requires hiding the outline and the drag points. I cannot do this and retain interactability. Is there a workaround?
Cheers,
-Dan
———————————————
P.S. I really dislike p-code. I understand the reason for it, but not being able to change simple properties and behaviors (such as making the drag points invisible) and not being able to figure out why is infuriating. image processing, rois, uix, p-code, images.roi.circle, get that drag point off my circle! MATLAB Answers — New Questions
Determine the maximum height and maximum width of the cross-sectional section from the stl file
I have a 3D scan file in stl format. I want to determine the maximum height and maximum width of 9 cross-sections at positions 10, 20,…90mm from the starting point. I have attached a sample file.
Who knows please help me. I sincerely thank youI have a 3D scan file in stl format. I want to determine the maximum height and maximum width of 9 cross-sections at positions 10, 20,…90mm from the starting point. I have attached a sample file.
Who knows please help me. I sincerely thank you I have a 3D scan file in stl format. I want to determine the maximum height and maximum width of 9 cross-sections at positions 10, 20,…90mm from the starting point. I have attached a sample file.
Who knows please help me. I sincerely thank you cross-sections, stl file MATLAB Answers — New Questions
Problems with sortrows function
I am trying to sort a two dimensional matrix Coord consisting of (x,y) pairs of coordinates (of size n x 2) in lexicographical order, with respect to x and then y. I used the command
[Coord_Lex,ix]=sortrows(Coord,[1,2]);
This should sort x coordinates in ascending order and within each set of matrix rows with the same x coordinate the y coordinates in ascending order. But in some cases it does not work correctly. For example, a part of the answer that I am getting is
1.2250 0.2067
1.2250 0.1722
1.2250 0.1378
1.2250 0.1033
1.2250 0.0689
1.2250 0.0344
1.2250 -0.2933
1.2250 -0.3278
1.2250 -0.3622
1.2250 -0.3967
1.2250 -0.4311
i.e., the y coordinaes are not sorted correctly. I checked the values of x coordinates in the incorrect part for the round-off error polution and the difference between them always gives 0.I am trying to sort a two dimensional matrix Coord consisting of (x,y) pairs of coordinates (of size n x 2) in lexicographical order, with respect to x and then y. I used the command
[Coord_Lex,ix]=sortrows(Coord,[1,2]);
This should sort x coordinates in ascending order and within each set of matrix rows with the same x coordinate the y coordinates in ascending order. But in some cases it does not work correctly. For example, a part of the answer that I am getting is
1.2250 0.2067
1.2250 0.1722
1.2250 0.1378
1.2250 0.1033
1.2250 0.0689
1.2250 0.0344
1.2250 -0.2933
1.2250 -0.3278
1.2250 -0.3622
1.2250 -0.3967
1.2250 -0.4311
i.e., the y coordinaes are not sorted correctly. I checked the values of x coordinates in the incorrect part for the round-off error polution and the difference between them always gives 0. I am trying to sort a two dimensional matrix Coord consisting of (x,y) pairs of coordinates (of size n x 2) in lexicographical order, with respect to x and then y. I used the command
[Coord_Lex,ix]=sortrows(Coord,[1,2]);
This should sort x coordinates in ascending order and within each set of matrix rows with the same x coordinate the y coordinates in ascending order. But in some cases it does not work correctly. For example, a part of the answer that I am getting is
1.2250 0.2067
1.2250 0.1722
1.2250 0.1378
1.2250 0.1033
1.2250 0.0689
1.2250 0.0344
1.2250 -0.2933
1.2250 -0.3278
1.2250 -0.3622
1.2250 -0.3967
1.2250 -0.4311
i.e., the y coordinaes are not sorted correctly. I checked the values of x coordinates in the incorrect part for the round-off error polution and the difference between them always gives 0. sortrows MATLAB Answers — New Questions
Using patternCustom to plot antenna Radiation Pattern in one figure
I’m using MATALAB R2020A with the Antenna toolbox to generate 2-D Plots of the measured Radiation Pattern (power in dBi) of an antenna, saved in an excel file. I wish to plot the Z-X Plane, and Z-Y Plane slice of the RP, but can’t seem to understand how to combine the "right side" and "left side" pattern to create one plot. As I understand it has to do with using the polarpattern class, but I cant seem to use it correctly. It would also be great to know how to fix the legend, and add a plot title.
clearvars; %clear all worskspace variables
close all; %Close all figures
%% ——Get data from excel sheet———
% %Get Anttena Powerb(dBi) data 13x17array
% filename=’RawAntennaData.xlsx’;
% H = table2array(readtable(filename,’Sheet’,’Horizontal’,’Range’,’B2:R14′));%
% %Get Theta (Elevation) and Phi (Azimuth) data, respectively a 13×1 and 1×17 array
% El= table2array(readtable(filename,’Sheet’,’Sheet1′,’Range’,’A2:A14′));%Elevation, "Vertical" Angle from 0 to pi
% Az = table2array(readtable(filename,’Sheet’,’Sheet1′,’Range’,’B1:R1′));%Azismuth, "Horizontal" angle -pi to pi
%% — Get data for Helix type antenna Radiation pattern—-
h = helix;
[H,Az,El] = pattern(h,2e9);
theta = El;
phi = Az’;
MagE = H’;
%% 3-D Plot of Antenna Radiation pattern
figure;
patternCustom(MAgE, theta, phi);% 3D plot in Polar cordinates
%% —– 2-D Plot of Z-X Plane (Theta) Cut with phi/Azimuth=90, in Polar coordinates ——-
figure; % Plot Z-X RP data points (for Y=0, phi=0°) at +X axis (right side)
A= patternCustom(MagE, theta, phi,’CoordinateSystem’,’polar’,’Slice’,’phi’,’SliceValue’,0);
%p = polarpattern(‘gco’);
%P = polarpattern(p,’TitleTop’,’Polar Pattern of Monopole’);
hold on
%figure; % Plot Z-X RP data points (for Y=0, phi=180°) at -X axis (left side)
B=patternCustom(MagE, theta, phi,’CoordinateSystem’,’polar’,’Slice’,’phi’,’SliceValue’,180);
hold off
legend(‘A’, ‘B’);I’m using MATALAB R2020A with the Antenna toolbox to generate 2-D Plots of the measured Radiation Pattern (power in dBi) of an antenna, saved in an excel file. I wish to plot the Z-X Plane, and Z-Y Plane slice of the RP, but can’t seem to understand how to combine the "right side" and "left side" pattern to create one plot. As I understand it has to do with using the polarpattern class, but I cant seem to use it correctly. It would also be great to know how to fix the legend, and add a plot title.
clearvars; %clear all worskspace variables
close all; %Close all figures
%% ——Get data from excel sheet———
% %Get Anttena Powerb(dBi) data 13x17array
% filename=’RawAntennaData.xlsx’;
% H = table2array(readtable(filename,’Sheet’,’Horizontal’,’Range’,’B2:R14′));%
% %Get Theta (Elevation) and Phi (Azimuth) data, respectively a 13×1 and 1×17 array
% El= table2array(readtable(filename,’Sheet’,’Sheet1′,’Range’,’A2:A14′));%Elevation, "Vertical" Angle from 0 to pi
% Az = table2array(readtable(filename,’Sheet’,’Sheet1′,’Range’,’B1:R1′));%Azismuth, "Horizontal" angle -pi to pi
%% — Get data for Helix type antenna Radiation pattern—-
h = helix;
[H,Az,El] = pattern(h,2e9);
theta = El;
phi = Az’;
MagE = H’;
%% 3-D Plot of Antenna Radiation pattern
figure;
patternCustom(MAgE, theta, phi);% 3D plot in Polar cordinates
%% —– 2-D Plot of Z-X Plane (Theta) Cut with phi/Azimuth=90, in Polar coordinates ——-
figure; % Plot Z-X RP data points (for Y=0, phi=0°) at +X axis (right side)
A= patternCustom(MagE, theta, phi,’CoordinateSystem’,’polar’,’Slice’,’phi’,’SliceValue’,0);
%p = polarpattern(‘gco’);
%P = polarpattern(p,’TitleTop’,’Polar Pattern of Monopole’);
hold on
%figure; % Plot Z-X RP data points (for Y=0, phi=180°) at -X axis (left side)
B=patternCustom(MagE, theta, phi,’CoordinateSystem’,’polar’,’Slice’,’phi’,’SliceValue’,180);
hold off
legend(‘A’, ‘B’); I’m using MATALAB R2020A with the Antenna toolbox to generate 2-D Plots of the measured Radiation Pattern (power in dBi) of an antenna, saved in an excel file. I wish to plot the Z-X Plane, and Z-Y Plane slice of the RP, but can’t seem to understand how to combine the "right side" and "left side" pattern to create one plot. As I understand it has to do with using the polarpattern class, but I cant seem to use it correctly. It would also be great to know how to fix the legend, and add a plot title.
clearvars; %clear all worskspace variables
close all; %Close all figures
%% ——Get data from excel sheet———
% %Get Anttena Powerb(dBi) data 13x17array
% filename=’RawAntennaData.xlsx’;
% H = table2array(readtable(filename,’Sheet’,’Horizontal’,’Range’,’B2:R14′));%
% %Get Theta (Elevation) and Phi (Azimuth) data, respectively a 13×1 and 1×17 array
% El= table2array(readtable(filename,’Sheet’,’Sheet1′,’Range’,’A2:A14′));%Elevation, "Vertical" Angle from 0 to pi
% Az = table2array(readtable(filename,’Sheet’,’Sheet1′,’Range’,’B1:R1′));%Azismuth, "Horizontal" angle -pi to pi
%% — Get data for Helix type antenna Radiation pattern—-
h = helix;
[H,Az,El] = pattern(h,2e9);
theta = El;
phi = Az’;
MagE = H’;
%% 3-D Plot of Antenna Radiation pattern
figure;
patternCustom(MAgE, theta, phi);% 3D plot in Polar cordinates
%% —– 2-D Plot of Z-X Plane (Theta) Cut with phi/Azimuth=90, in Polar coordinates ——-
figure; % Plot Z-X RP data points (for Y=0, phi=0°) at +X axis (right side)
A= patternCustom(MagE, theta, phi,’CoordinateSystem’,’polar’,’Slice’,’phi’,’SliceValue’,0);
%p = polarpattern(‘gco’);
%P = polarpattern(p,’TitleTop’,’Polar Pattern of Monopole’);
hold on
%figure; % Plot Z-X RP data points (for Y=0, phi=180°) at -X axis (left side)
B=patternCustom(MagE, theta, phi,’CoordinateSystem’,’polar’,’Slice’,’phi’,’SliceValue’,180);
hold off
legend(‘A’, ‘B’); patterncustom, antenna toolbox, polarpattern class, 2d polar plots MATLAB Answers — New Questions
Adams, Simulink, and Reinforcement Learning
Build a model using Adams and combine it with MATLAB’s Simulink for reinforcement learning. However, at the beginning of each training round, the Adams model always continues the previous state. How to make the model start from the initial state in each round?Build a model using Adams and combine it with MATLAB’s Simulink for reinforcement learning. However, at the beginning of each training round, the Adams model always continues the previous state. How to make the model start from the initial state in each round? Build a model using Adams and combine it with MATLAB’s Simulink for reinforcement learning. However, at the beginning of each training round, the Adams model always continues the previous state. How to make the model start from the initial state in each round? adams, simulink, reinforcement learning MATLAB Answers — New Questions
Creating a grid on an image at an angle with a specific spacing
Hey All
The summary is it all. Basically I have an image and a code that draws two "axes" lines a red and blue line. I basically want to form a grid using lines parellel to those in order to find their intersects and plot other circles where they intersect.
I have provided an image for clarification!Hey All
The summary is it all. Basically I have an image and a code that draws two "axes" lines a red and blue line. I basically want to form a grid using lines parellel to those in order to find their intersects and plot other circles where they intersect.
I have provided an image for clarification! Hey All
The summary is it all. Basically I have an image and a code that draws two "axes" lines a red and blue line. I basically want to form a grid using lines parellel to those in order to find their intersects and plot other circles where they intersect.
I have provided an image for clarification! image analysis, image processing, image analyst MATLAB Answers — New Questions
How can I develop a matlab code that used to fine the phase profile of a Reconfigurable intelligent surface? with contains a beamforming algorithm to locate the received wave
The code with a beamforming algorithm
How can I get the sample values for the input and output values
Create the RIS by defining its size, position, and reflection coefficients
equation to calculate the reflected waveThe code with a beamforming algorithm
How can I get the sample values for the input and output values
Create the RIS by defining its size, position, and reflection coefficients
equation to calculate the reflected wave The code with a beamforming algorithm
How can I get the sample values for the input and output values
Create the RIS by defining its size, position, and reflection coefficients
equation to calculate the reflected wave #ris, beamform MATLAB Answers — New Questions