Category: Matlab
Category Archives: Matlab
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
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
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
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
Arduino Uno and Matlab Simulink using IR sensor and LCD I2C display only
Hi,
I’m building my project with Arduino Uno and Matlab Simulink using IR sensor and LCD I2C display only. In my project, My concept is that I want the IR sensor to detect the object and the I2c display to start the counting in seconds. If the sensor detects another object, the counting should stop immediately.
if any could help, thnks in advancedHi,
I’m building my project with Arduino Uno and Matlab Simulink using IR sensor and LCD I2C display only. In my project, My concept is that I want the IR sensor to detect the object and the I2c display to start the counting in seconds. If the sensor detects another object, the counting should stop immediately.
if any could help, thnks in advanced Hi,
I’m building my project with Arduino Uno and Matlab Simulink using IR sensor and LCD I2C display only. In my project, My concept is that I want the IR sensor to detect the object and the I2c display to start the counting in seconds. If the sensor detects another object, the counting should stop immediately.
if any could help, thnks in advanced ir_sensor, simulink MATLAB Answers — New Questions
How do I extract column name of table in MATLAB?
Can you suggest me a way to extract name of specific column of table in MATLAB?Can you suggest me a way to extract name of specific column of table in MATLAB? Can you suggest me a way to extract name of specific column of table in MATLAB? table, uitable MATLAB Answers — New Questions
Using Simulink for Solver use
Hello Matlab,
I have taken the help of last advise given by Matlab. I found out navigation etc. My issue currently is:
I have uploaded one file to Matlab Drive.
In the Simulink, I tried to import data. It did not work but there in the drive.
Then I clicked on New Script, pasted script and Saved it. But nothings happening when I clicked on RUN button.
My need is, I have a mathematical model, non linear, in the excel. The script defines Objective functions, Variable cells and Constraints. This was AI generated. I wanted to optimise that. Is there an alternative to script and if not, can I have tutorials on how to write a Matlab code for : Objective functions, Variable cells and Constraints?
Regards.Hello Matlab,
I have taken the help of last advise given by Matlab. I found out navigation etc. My issue currently is:
I have uploaded one file to Matlab Drive.
In the Simulink, I tried to import data. It did not work but there in the drive.
Then I clicked on New Script, pasted script and Saved it. But nothings happening when I clicked on RUN button.
My need is, I have a mathematical model, non linear, in the excel. The script defines Objective functions, Variable cells and Constraints. This was AI generated. I wanted to optimise that. Is there an alternative to script and if not, can I have tutorials on how to write a Matlab code for : Objective functions, Variable cells and Constraints?
Regards. Hello Matlab,
I have taken the help of last advise given by Matlab. I found out navigation etc. My issue currently is:
I have uploaded one file to Matlab Drive.
In the Simulink, I tried to import data. It did not work but there in the drive.
Then I clicked on New Script, pasted script and Saved it. But nothings happening when I clicked on RUN button.
My need is, I have a mathematical model, non linear, in the excel. The script defines Objective functions, Variable cells and Constraints. This was AI generated. I wanted to optimise that. Is there an alternative to script and if not, can I have tutorials on how to write a Matlab code for : Objective functions, Variable cells and Constraints?
Regards. solver MATLAB Answers — New Questions
How to remove noise of low frequency signals
Hello,
I have to create a model of following signal in such a way a way that red signal will not fluctuate with the green signal and will always take mean of green signal. I have used moving average filter, but still there is some fluctuation, I cannot increase N of moving average filter, since it will make it less responsive. Could you suggest me such a way where I could make red signals more or less like straight tine. is there any filter or algorithm available for this.
Note – this signal manipulation should be done in realtime, model is created in SimulinkHello,
I have to create a model of following signal in such a way a way that red signal will not fluctuate with the green signal and will always take mean of green signal. I have used moving average filter, but still there is some fluctuation, I cannot increase N of moving average filter, since it will make it less responsive. Could you suggest me such a way where I could make red signals more or less like straight tine. is there any filter or algorithm available for this.
Note – this signal manipulation should be done in realtime, model is created in Simulink Hello,
I have to create a model of following signal in such a way a way that red signal will not fluctuate with the green signal and will always take mean of green signal. I have used moving average filter, but still there is some fluctuation, I cannot increase N of moving average filter, since it will make it less responsive. Could you suggest me such a way where I could make red signals more or less like straight tine. is there any filter or algorithm available for this.
Note – this signal manipulation should be done in realtime, model is created in Simulink filter, low frequency, signal processing MATLAB Answers — New Questions
for double for loop error
syms x t%a g d l1 m1
%%%%%%%%%%%%%%%% Fractional Order%
alpha=2;
beta=1;
%%%%%%%%%%%% initilization of variable%%%%%%
U=zeros(1,2,’sym’);
V=zeros(1,2,’sym’);
A=zeros(1,2,’sym’);
B=zeros(1,2,’sym’);
C=zeros(1,2,’sym’);
D=zeros(1,2,’sym’);
E=zeros(1,2,’sym’);
F=zeros(1,2,’sym’);
G=zeros(1,2,’sym’);
series1(x,t)=sym(zeros(1,1));
series2(x,t)=sym(zeros(1,1));
a=1;
g=0.01;
d=0.01;
l1=-(4/9)*g^4*d+(16/27)*g^6-(5/9)*g^2*d^2-(5/54)*d^3;
m1=20*g^4*d-16*g^6+5*g^2*d^2;
U(1)=a-2*g*cot(g*x);
U(2)=-2*g^2*d*csc(g*x)*csc(g*x);
V(1)=l1-(1/9)*m1*cot(g*x)*cot(g*x);
for k=1:3
A(1)=0;
B(1)=0;
C(1)=0;
D(1)=0;
E(1)=0;
F(1)=0;
G(1)=0;
for r=1:k
A(1)=A(1)+diff(U(r),x,2)*diff(U(k-r+1),x,3);
B(1)=B(1)+diff(U(r),x,1)*diff(U(k-r+1),x,4);
D(1)=D(1)+diff(U(r),x,2)*(k-r+1)*U(k-r+1);
E(1)=E(1)+diff(U(r),x,1)*(k-r+1)*diff(U(k-r+1),x,1);
F(1)=F(1)+diff(V(r),x,1)*diff(U(k-r+1),x,1);
G(1)=G(1)+V(r)*diff(U(k-r+1),x,2);
for l=1:r
C(1)=C(1)+diff(U(l),x,1)*diff(U(r-l+1),x,1)*diff(U(k-r+1),x,2);% 4th term
end
end
U(k+2)=gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*((1/5)*diff(U(k),x,6)+3*A(1)+3*B(1)+9*C(1)-(k)*diff(U(k+1),x,2)-3*D(1)-3*E(1)+(18/5)*diff(V(k),x,1))
V(k+1)=gamma(((k-1)*beta)+1)/gamma((beta*(k+1-1))+1)*(diff(V(k),x,3)+3*F(1)+3*G(1));
end
for k=1:2
series1(x,t)=simplify(series1(x,t)+U(k)*power(t,k-1));
series2(x,t)=simplify(series2(x,t)+V(k)*power(t,k-1));
end
series1
series2
row=0
for r=1:10:110
row=row+1;
col=0;
e=r-1
for t=1
col=col+1;
f=t+19
C1(row,col)=series1(e,f);
C2(row,col)=series2(e,f);
end
end
vpa(C1,15)
vpa(C2,15)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x=10:10:100
t=20
row=0
for i=1:length(x)
row=row+1
col=col+1
for j=1:length(t)
C1(row, col) =series1(x(i), t(i))
C2(row,col) =series2(x(i),t(i))
end
end
This two for loop shows thw different value of C1 and C2 . The first for loop gives the correct value for C1 but not C2. But the second loop give both wrong
.
I want know the value of x anf t are same then why for loop show two different valuesyms x t%a g d l1 m1
%%%%%%%%%%%%%%%% Fractional Order%
alpha=2;
beta=1;
%%%%%%%%%%%% initilization of variable%%%%%%
U=zeros(1,2,’sym’);
V=zeros(1,2,’sym’);
A=zeros(1,2,’sym’);
B=zeros(1,2,’sym’);
C=zeros(1,2,’sym’);
D=zeros(1,2,’sym’);
E=zeros(1,2,’sym’);
F=zeros(1,2,’sym’);
G=zeros(1,2,’sym’);
series1(x,t)=sym(zeros(1,1));
series2(x,t)=sym(zeros(1,1));
a=1;
g=0.01;
d=0.01;
l1=-(4/9)*g^4*d+(16/27)*g^6-(5/9)*g^2*d^2-(5/54)*d^3;
m1=20*g^4*d-16*g^6+5*g^2*d^2;
U(1)=a-2*g*cot(g*x);
U(2)=-2*g^2*d*csc(g*x)*csc(g*x);
V(1)=l1-(1/9)*m1*cot(g*x)*cot(g*x);
for k=1:3
A(1)=0;
B(1)=0;
C(1)=0;
D(1)=0;
E(1)=0;
F(1)=0;
G(1)=0;
for r=1:k
A(1)=A(1)+diff(U(r),x,2)*diff(U(k-r+1),x,3);
B(1)=B(1)+diff(U(r),x,1)*diff(U(k-r+1),x,4);
D(1)=D(1)+diff(U(r),x,2)*(k-r+1)*U(k-r+1);
E(1)=E(1)+diff(U(r),x,1)*(k-r+1)*diff(U(k-r+1),x,1);
F(1)=F(1)+diff(V(r),x,1)*diff(U(k-r+1),x,1);
G(1)=G(1)+V(r)*diff(U(k-r+1),x,2);
for l=1:r
C(1)=C(1)+diff(U(l),x,1)*diff(U(r-l+1),x,1)*diff(U(k-r+1),x,2);% 4th term
end
end
U(k+2)=gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*((1/5)*diff(U(k),x,6)+3*A(1)+3*B(1)+9*C(1)-(k)*diff(U(k+1),x,2)-3*D(1)-3*E(1)+(18/5)*diff(V(k),x,1))
V(k+1)=gamma(((k-1)*beta)+1)/gamma((beta*(k+1-1))+1)*(diff(V(k),x,3)+3*F(1)+3*G(1));
end
for k=1:2
series1(x,t)=simplify(series1(x,t)+U(k)*power(t,k-1));
series2(x,t)=simplify(series2(x,t)+V(k)*power(t,k-1));
end
series1
series2
row=0
for r=1:10:110
row=row+1;
col=0;
e=r-1
for t=1
col=col+1;
f=t+19
C1(row,col)=series1(e,f);
C2(row,col)=series2(e,f);
end
end
vpa(C1,15)
vpa(C2,15)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x=10:10:100
t=20
row=0
for i=1:length(x)
row=row+1
col=col+1
for j=1:length(t)
C1(row, col) =series1(x(i), t(i))
C2(row,col) =series2(x(i),t(i))
end
end
This two for loop shows thw different value of C1 and C2 . The first for loop gives the correct value for C1 but not C2. But the second loop give both wrong
.
I want know the value of x anf t are same then why for loop show two different value syms x t%a g d l1 m1
%%%%%%%%%%%%%%%% Fractional Order%
alpha=2;
beta=1;
%%%%%%%%%%%% initilization of variable%%%%%%
U=zeros(1,2,’sym’);
V=zeros(1,2,’sym’);
A=zeros(1,2,’sym’);
B=zeros(1,2,’sym’);
C=zeros(1,2,’sym’);
D=zeros(1,2,’sym’);
E=zeros(1,2,’sym’);
F=zeros(1,2,’sym’);
G=zeros(1,2,’sym’);
series1(x,t)=sym(zeros(1,1));
series2(x,t)=sym(zeros(1,1));
a=1;
g=0.01;
d=0.01;
l1=-(4/9)*g^4*d+(16/27)*g^6-(5/9)*g^2*d^2-(5/54)*d^3;
m1=20*g^4*d-16*g^6+5*g^2*d^2;
U(1)=a-2*g*cot(g*x);
U(2)=-2*g^2*d*csc(g*x)*csc(g*x);
V(1)=l1-(1/9)*m1*cot(g*x)*cot(g*x);
for k=1:3
A(1)=0;
B(1)=0;
C(1)=0;
D(1)=0;
E(1)=0;
F(1)=0;
G(1)=0;
for r=1:k
A(1)=A(1)+diff(U(r),x,2)*diff(U(k-r+1),x,3);
B(1)=B(1)+diff(U(r),x,1)*diff(U(k-r+1),x,4);
D(1)=D(1)+diff(U(r),x,2)*(k-r+1)*U(k-r+1);
E(1)=E(1)+diff(U(r),x,1)*(k-r+1)*diff(U(k-r+1),x,1);
F(1)=F(1)+diff(V(r),x,1)*diff(U(k-r+1),x,1);
G(1)=G(1)+V(r)*diff(U(k-r+1),x,2);
for l=1:r
C(1)=C(1)+diff(U(l),x,1)*diff(U(r-l+1),x,1)*diff(U(k-r+1),x,2);% 4th term
end
end
U(k+2)=gamma(((k-1)*alpha)+1)/gamma((alpha*(k+1-1))+1)*((1/5)*diff(U(k),x,6)+3*A(1)+3*B(1)+9*C(1)-(k)*diff(U(k+1),x,2)-3*D(1)-3*E(1)+(18/5)*diff(V(k),x,1))
V(k+1)=gamma(((k-1)*beta)+1)/gamma((beta*(k+1-1))+1)*(diff(V(k),x,3)+3*F(1)+3*G(1));
end
for k=1:2
series1(x,t)=simplify(series1(x,t)+U(k)*power(t,k-1));
series2(x,t)=simplify(series2(x,t)+V(k)*power(t,k-1));
end
series1
series2
row=0
for r=1:10:110
row=row+1;
col=0;
e=r-1
for t=1
col=col+1;
f=t+19
C1(row,col)=series1(e,f);
C2(row,col)=series2(e,f);
end
end
vpa(C1,15)
vpa(C2,15)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x=10:10:100
t=20
row=0
for i=1:length(x)
row=row+1
col=col+1
for j=1:length(t)
C1(row, col) =series1(x(i), t(i))
C2(row,col) =series2(x(i),t(i))
end
end
This two for loop shows thw different value of C1 and C2 . The first for loop gives the correct value for C1 but not C2. But the second loop give both wrong
.
I want know the value of x anf t are same then why for loop show two different value for loop error MATLAB Answers — New Questions
Problem with matrix dimensions
Hello, my code is giving me the error :
Error using
Matrix dimensions must agree.
I don’t know why because the matrices I am trying to divide have the dimensions of 5×1 and 5×5
function F = sistema(X)
beta1 = 0.0000009;
beta2 = 0.00000093;
M = 1;
p = 0.1;
mu = 0.00001;
rho = 0.00002;
theta = 0.005;
omega = 0.05;
gamma = 0.001;
alpha1 = 0.0001;
alpha2 = 0.004;
S = X(1);
E = X(2);
I = X(3);
Q = X(4);
V = X(5);
F(1) = p*M – beta1*S*E – beta2*S*I – (rho + mu)*S;
F(2) = beta1*S*E + beta2*S*I – (omega + alpha1 + mu)*E;
F(3) = omega*E – (gamma + alpha2 + mu)*I;
F(4) = alpha1*E + alpha2*I – (theta + mu)*Q;
F(5) = (1 – p)*M + rho*S + gamma*I + theta*Q – mu*V;
end
function JF = jacobiano(X)
beta1 = 0.0000009;
beta2 = 0.00000093;
M = 1;
p = 0.1;
mu = 0.00001;
rho = 0.00002;
theta = 0.005;
omega = 0.05;
gamma = 0.001;
alpha1 = 0.0001;
alpha2 = 0.004;
S = X(1);
E = X(2);
I = X(3);
Q = X(4);
V = X(5);
JF = [-beta1*E – beta2*I – rho – mu, -beta1*S, -beta2*S, 0, 0;
beta1*E, beta1*S – (omega + alpha1 + mu), beta2*S, 0, 0;
0, omega, -(gamma + alpha2 + mu), 0, 0;
0, alpha1, alpha2, -(theta + mu), 0;
rho, 0, gamma, theta, -mu];
end
These are the codes of the two functions that qive the matrices
function [x, it, norma_diferenca] = metodo_newton2(F, JF, y0, e, nmax)
x = y0;
it = 0;
norma_diferenca = Inf;
while norma_diferenca > e && it < nmax
Fx = F(x);
JFx = JF(x);
div = JFx (-Fx);
x = x + div;
norma_diferenca = norm(div);
it = it + 1;
end
if it >= nmax
disp(‘Atingido o número máximo de iterações sem convergência.’);
end
end
And this is the code taht divide the two matrices.Hello, my code is giving me the error :
Error using
Matrix dimensions must agree.
I don’t know why because the matrices I am trying to divide have the dimensions of 5×1 and 5×5
function F = sistema(X)
beta1 = 0.0000009;
beta2 = 0.00000093;
M = 1;
p = 0.1;
mu = 0.00001;
rho = 0.00002;
theta = 0.005;
omega = 0.05;
gamma = 0.001;
alpha1 = 0.0001;
alpha2 = 0.004;
S = X(1);
E = X(2);
I = X(3);
Q = X(4);
V = X(5);
F(1) = p*M – beta1*S*E – beta2*S*I – (rho + mu)*S;
F(2) = beta1*S*E + beta2*S*I – (omega + alpha1 + mu)*E;
F(3) = omega*E – (gamma + alpha2 + mu)*I;
F(4) = alpha1*E + alpha2*I – (theta + mu)*Q;
F(5) = (1 – p)*M + rho*S + gamma*I + theta*Q – mu*V;
end
function JF = jacobiano(X)
beta1 = 0.0000009;
beta2 = 0.00000093;
M = 1;
p = 0.1;
mu = 0.00001;
rho = 0.00002;
theta = 0.005;
omega = 0.05;
gamma = 0.001;
alpha1 = 0.0001;
alpha2 = 0.004;
S = X(1);
E = X(2);
I = X(3);
Q = X(4);
V = X(5);
JF = [-beta1*E – beta2*I – rho – mu, -beta1*S, -beta2*S, 0, 0;
beta1*E, beta1*S – (omega + alpha1 + mu), beta2*S, 0, 0;
0, omega, -(gamma + alpha2 + mu), 0, 0;
0, alpha1, alpha2, -(theta + mu), 0;
rho, 0, gamma, theta, -mu];
end
These are the codes of the two functions that qive the matrices
function [x, it, norma_diferenca] = metodo_newton2(F, JF, y0, e, nmax)
x = y0;
it = 0;
norma_diferenca = Inf;
while norma_diferenca > e && it < nmax
Fx = F(x);
JFx = JF(x);
div = JFx (-Fx);
x = x + div;
norma_diferenca = norm(div);
it = it + 1;
end
if it >= nmax
disp(‘Atingido o número máximo de iterações sem convergência.’);
end
end
And this is the code taht divide the two matrices. Hello, my code is giving me the error :
Error using
Matrix dimensions must agree.
I don’t know why because the matrices I am trying to divide have the dimensions of 5×1 and 5×5
function F = sistema(X)
beta1 = 0.0000009;
beta2 = 0.00000093;
M = 1;
p = 0.1;
mu = 0.00001;
rho = 0.00002;
theta = 0.005;
omega = 0.05;
gamma = 0.001;
alpha1 = 0.0001;
alpha2 = 0.004;
S = X(1);
E = X(2);
I = X(3);
Q = X(4);
V = X(5);
F(1) = p*M – beta1*S*E – beta2*S*I – (rho + mu)*S;
F(2) = beta1*S*E + beta2*S*I – (omega + alpha1 + mu)*E;
F(3) = omega*E – (gamma + alpha2 + mu)*I;
F(4) = alpha1*E + alpha2*I – (theta + mu)*Q;
F(5) = (1 – p)*M + rho*S + gamma*I + theta*Q – mu*V;
end
function JF = jacobiano(X)
beta1 = 0.0000009;
beta2 = 0.00000093;
M = 1;
p = 0.1;
mu = 0.00001;
rho = 0.00002;
theta = 0.005;
omega = 0.05;
gamma = 0.001;
alpha1 = 0.0001;
alpha2 = 0.004;
S = X(1);
E = X(2);
I = X(3);
Q = X(4);
V = X(5);
JF = [-beta1*E – beta2*I – rho – mu, -beta1*S, -beta2*S, 0, 0;
beta1*E, beta1*S – (omega + alpha1 + mu), beta2*S, 0, 0;
0, omega, -(gamma + alpha2 + mu), 0, 0;
0, alpha1, alpha2, -(theta + mu), 0;
rho, 0, gamma, theta, -mu];
end
These are the codes of the two functions that qive the matrices
function [x, it, norma_diferenca] = metodo_newton2(F, JF, y0, e, nmax)
x = y0;
it = 0;
norma_diferenca = Inf;
while norma_diferenca > e && it < nmax
Fx = F(x);
JFx = JF(x);
div = JFx (-Fx);
x = x + div;
norma_diferenca = norm(div);
it = it + 1;
end
if it >= nmax
disp(‘Atingido o número máximo de iterações sem convergência.’);
end
end
And this is the code taht divide the two matrices. matlab, matrices, division MATLAB Answers — New Questions
How to save videos in a MATALB standalone application?
I am trying to build a standalone application using MATLAB App Designer. In that, I want to play videos according to the given instructions or keywords. Those videos are saved on my desktop. How should I proceed in building the standalone application so that to play these videos after installing the application on any other target desktop system (without having/saving the videos on the target system)?
Can anyone suggest some way out?
Feel free to comment if my query is not clearI am trying to build a standalone application using MATLAB App Designer. In that, I want to play videos according to the given instructions or keywords. Those videos are saved on my desktop. How should I proceed in building the standalone application so that to play these videos after installing the application on any other target desktop system (without having/saving the videos on the target system)?
Can anyone suggest some way out?
Feel free to comment if my query is not clear I am trying to build a standalone application using MATLAB App Designer. In that, I want to play videos according to the given instructions or keywords. Those videos are saved on my desktop. How should I proceed in building the standalone application so that to play these videos after installing the application on any other target desktop system (without having/saving the videos on the target system)?
Can anyone suggest some way out?
Feel free to comment if my query is not clear appdesigner, matlab, app designer, matlab gui MATLAB Answers — New Questions