Category: Matlab
Category Archives: Matlab
How do I convert a 24 bit depth image file to an 8 bit depth image file?
I have a 24 bit depth image that needs to be used in a different program. This program however needs only an image of 8 bit depth. I want to be able to change the bit depth at will when generating a TIFF file using MATLAB.I have a 24 bit depth image that needs to be used in a different program. This program however needs only an image of 8 bit depth. I want to be able to change the bit depth at will when generating a TIFF file using MATLAB. I have a 24 bit depth image that needs to be used in a different program. This program however needs only an image of 8 bit depth. I want to be able to change the bit depth at will when generating a TIFF file using MATLAB. bit, depth, tiff, 24, 8, image, processing, convert MATLAB Answers — New Questions
how can i use my GPU from openVPN to my matlab
how can i use my GPU from openVPN to my matlabhow can i use my GPU from openVPN to my matlab how can i use my GPU from openVPN to my matlab ssh, ssl, remote MATLAB Answers — New Questions
If I want to get a radial profile on an image, which program should I use?
I want to get a radial profile for a circular signal on an image.
I am currently wondering which of the following two programs I should use.
https://jp.mathworks.com/matlabcentral/answers/276298-how-to-plot-the-radial-profile-of-a-2d-image
https://jp.mathworks.com/matlabcentral/fileexchange/101480-very-fast-radial-profile
I have tried both and got different profiles.
Which one is more accurate? I would appreciate your answer.I want to get a radial profile for a circular signal on an image.
I am currently wondering which of the following two programs I should use.
https://jp.mathworks.com/matlabcentral/answers/276298-how-to-plot-the-radial-profile-of-a-2d-image
https://jp.mathworks.com/matlabcentral/fileexchange/101480-very-fast-radial-profile
I have tried both and got different profiles.
Which one is more accurate? I would appreciate your answer. I want to get a radial profile for a circular signal on an image.
I am currently wondering which of the following two programs I should use.
https://jp.mathworks.com/matlabcentral/answers/276298-how-to-plot-the-radial-profile-of-a-2d-image
https://jp.mathworks.com/matlabcentral/fileexchange/101480-very-fast-radial-profile
I have tried both and got different profiles.
Which one is more accurate? I would appreciate your answer. image, radial profile MATLAB Answers — New Questions
Write a function called halfsum that takes as input an at most two-dimensional matrix A and computes the sum of the elements of A that are in the diagonal or are to the right of it. example, the input is [1 2 3; 4 5 6; 7 8 9],the ans is 26
function s = halfsum(A)
[row col] = size(A);
if row ~= col
error(‘Expecting a square matrix here people…’);
end
s = 0;
for ii = 1:row
for jj = ii:col
s = s + A(ii,jj);
end
endfunction s = halfsum(A)
[row col] = size(A);
if row ~= col
error(‘Expecting a square matrix here people…’);
end
s = 0;
for ii = 1:row
for jj = ii:col
s = s + A(ii,jj);
end
end function s = halfsum(A)
[row col] = size(A);
if row ~= col
error(‘Expecting a square matrix here people…’);
end
s = 0;
for ii = 1:row
for jj = ii:col
s = s + A(ii,jj);
end
end homework, soft-lock, no more solutions please!!!!!!, make me cry MATLAB Answers — New Questions
PIV image correlation function
Hi all,
I trying to correlate PIV images ( about 100 image). I used the below code that can correlate only the first 2 pair of images and I want to modify the loop so it can correlate the rest images. can somebody help me in modifying the loop?
for i= 1: 100;
for j= 1: 100;
max_correlation=0;
test_xmin=xgrid(i);
test_xmax=xgrid(j)+ 20 %w_width/2;
test_ymin=ygrid(i);
test_ymax=ygrid(j)+ 20 %w_width/2;
x_disp=0;
y_disp=0;
test_ima= Imagea(test_xmin:test_xmax, test_ymin:test_ymax);
test_imb= Imageb(test_xmin-x_disp_max:test_xmax+x_disp_max, test_ymin-y_disp_max:test_ymax+ y_disp_max);
correlation= normxcorr2(test_ima, test_imb);
[xpeak, ypeak]= find (correlation==max(correlation(:) ));
end
end
thanks in advanceHi all,
I trying to correlate PIV images ( about 100 image). I used the below code that can correlate only the first 2 pair of images and I want to modify the loop so it can correlate the rest images. can somebody help me in modifying the loop?
for i= 1: 100;
for j= 1: 100;
max_correlation=0;
test_xmin=xgrid(i);
test_xmax=xgrid(j)+ 20 %w_width/2;
test_ymin=ygrid(i);
test_ymax=ygrid(j)+ 20 %w_width/2;
x_disp=0;
y_disp=0;
test_ima= Imagea(test_xmin:test_xmax, test_ymin:test_ymax);
test_imb= Imageb(test_xmin-x_disp_max:test_xmax+x_disp_max, test_ymin-y_disp_max:test_ymax+ y_disp_max);
correlation= normxcorr2(test_ima, test_imb);
[xpeak, ypeak]= find (correlation==max(correlation(:) ));
end
end
thanks in advance Hi all,
I trying to correlate PIV images ( about 100 image). I used the below code that can correlate only the first 2 pair of images and I want to modify the loop so it can correlate the rest images. can somebody help me in modifying the loop?
for i= 1: 100;
for j= 1: 100;
max_correlation=0;
test_xmin=xgrid(i);
test_xmax=xgrid(j)+ 20 %w_width/2;
test_ymin=ygrid(i);
test_ymax=ygrid(j)+ 20 %w_width/2;
x_disp=0;
y_disp=0;
test_ima= Imagea(test_xmin:test_xmax, test_ymin:test_ymax);
test_imb= Imageb(test_xmin-x_disp_max:test_xmax+x_disp_max, test_ymin-y_disp_max:test_ymax+ y_disp_max);
correlation= normxcorr2(test_ima, test_imb);
[xpeak, ypeak]= find (correlation==max(correlation(:) ));
end
end
thanks in advance piv image correlation MATLAB Answers — New Questions
How i can write 12 bit rgb image in matlab ?
Dear All,
my goal is to write 12 bit rgb (4 bit for Red, 4 bit for Green, and 4 bit for Blue) image in Matlab.
I already have the image array with size (32,32,3) with range value on 0-15 for each cell.
Does anyone have already done it?
Please let me know if my explanation is not clear.
Thanks.Dear All,
my goal is to write 12 bit rgb (4 bit for Red, 4 bit for Green, and 4 bit for Blue) image in Matlab.
I already have the image array with size (32,32,3) with range value on 0-15 for each cell.
Does anyone have already done it?
Please let me know if my explanation is not clear.
Thanks. Dear All,
my goal is to write 12 bit rgb (4 bit for Red, 4 bit for Green, and 4 bit for Blue) image in Matlab.
I already have the image array with size (32,32,3) with range value on 0-15 for each cell.
Does anyone have already done it?
Please let me know if my explanation is not clear.
Thanks. image processing MATLAB Answers — New Questions
How do I set up MATLAB as the diff and merge tool for TortoiseGit?
I am using TortoiseGit to manage changes to a repository which contains binary files, such as Simulink models (".slx" or ".mdl" files) or live scripts (".mlx" files).
However, when I attempt to diff or merge these files, git fails because they are not text. How do I configure TortoiseGit to use MATLAB’s diff and merge tools for these file types?I am using TortoiseGit to manage changes to a repository which contains binary files, such as Simulink models (".slx" or ".mdl" files) or live scripts (".mlx" files).
However, when I attempt to diff or merge these files, git fails because they are not text. How do I configure TortoiseGit to use MATLAB’s diff and merge tools for these file types? I am using TortoiseGit to manage changes to a repository which contains binary files, such as Simulink models (".slx" or ".mdl" files) or live scripts (".mlx" files).
However, when I attempt to diff or merge these files, git fails because they are not text. How do I configure TortoiseGit to use MATLAB’s diff and merge tools for these file types? MATLAB Answers — New Questions
Read and Write in one scatch
Is it possible in one Arduino sketch to write data to one ThingSpeak field and read data from another field?Is it possible in one Arduino sketch to write data to one ThingSpeak field and read data from another field? Is it possible in one Arduino sketch to write data to one ThingSpeak field and read data from another field? thingspeak MATLAB Answers — New Questions
Any way to automatically save my LiveScript .mlx file as a Text-based .m file?
As given here, LiveScript is rather unhelpful for source control in terms of tractability and interpretation.
https://www.mathworks.com/matlabcentral/answers/271488-how-do-i-use-live-script-mlx-files-in-source-control
I like using LiveScript, but want the ease of source control of a text-based file, such as .m files.
Sometimes, I manually save (a copy of) the LiveScript as a .m file, so that the latest changes may be interpreted in git. Is there a way to automatically copy/save a .m file every time I save the .mlx file?, instead of manually clicking some menu options? This is one way I hope I can access the ease of writing in LiveScript while not compromising on the ease of source control.As given here, LiveScript is rather unhelpful for source control in terms of tractability and interpretation.
https://www.mathworks.com/matlabcentral/answers/271488-how-do-i-use-live-script-mlx-files-in-source-control
I like using LiveScript, but want the ease of source control of a text-based file, such as .m files.
Sometimes, I manually save (a copy of) the LiveScript as a .m file, so that the latest changes may be interpreted in git. Is there a way to automatically copy/save a .m file every time I save the .mlx file?, instead of manually clicking some menu options? This is one way I hope I can access the ease of writing in LiveScript while not compromising on the ease of source control. As given here, LiveScript is rather unhelpful for source control in terms of tractability and interpretation.
https://www.mathworks.com/matlabcentral/answers/271488-how-do-i-use-live-script-mlx-files-in-source-control
I like using LiveScript, but want the ease of source control of a text-based file, such as .m files.
Sometimes, I manually save (a copy of) the LiveScript as a .m file, so that the latest changes may be interpreted in git. Is there a way to automatically copy/save a .m file every time I save the .mlx file?, instead of manually clicking some menu options? This is one way I hope I can access the ease of writing in LiveScript while not compromising on the ease of source control. livescript, source control, 2023a MATLAB Answers — New Questions
Trying to make a 2 value sz vector, get Error using tabular/horzcat All input arguments must be tables.
Seems so simple, I’m trying to set a new table size based on values in a previous table
C = sum(app.UITable2.Data(1,:));
No matter how hard I try I can’t get the sum of a single column!
So I give up and do
sz = [C(1,1) 4];
Get the weird error that all inputs must be tables!
Try making sz a known vector type
make a property sz = [4 4]
then try
app.sz = [C(1,1) 4];
Sorry for all the asks but I’m a very experienced C, C++ (and many other languages) programmer but this .m code is driving me crazy! Help give all kinds of useless details about setting Fonts etc but little about simple syntax for e.g. summing a column.
S = sum(A,1); does sum by columns (vs ,2 for by rows but no way to say just do column 1. Even though C is a 1×4 Can’t seem to get the scaler C(1,1) out of it properly.
C(1,1) or C(1) works in the command line, just not in my app created by app designer.
Ultimately all I really want is to make a new table of the correct size with
app.TrialsTable = table(‘Size’,sz,’VariableTypes’,{‘uint8′,’uint8′,’categorical’,’int16′});Seems so simple, I’m trying to set a new table size based on values in a previous table
C = sum(app.UITable2.Data(1,:));
No matter how hard I try I can’t get the sum of a single column!
So I give up and do
sz = [C(1,1) 4];
Get the weird error that all inputs must be tables!
Try making sz a known vector type
make a property sz = [4 4]
then try
app.sz = [C(1,1) 4];
Sorry for all the asks but I’m a very experienced C, C++ (and many other languages) programmer but this .m code is driving me crazy! Help give all kinds of useless details about setting Fonts etc but little about simple syntax for e.g. summing a column.
S = sum(A,1); does sum by columns (vs ,2 for by rows but no way to say just do column 1. Even though C is a 1×4 Can’t seem to get the scaler C(1,1) out of it properly.
C(1,1) or C(1) works in the command line, just not in my app created by app designer.
Ultimately all I really want is to make a new table of the correct size with
app.TrialsTable = table(‘Size’,sz,’VariableTypes’,{‘uint8′,’uint8′,’categorical’,’int16′}); Seems so simple, I’m trying to set a new table size based on values in a previous table
C = sum(app.UITable2.Data(1,:));
No matter how hard I try I can’t get the sum of a single column!
So I give up and do
sz = [C(1,1) 4];
Get the weird error that all inputs must be tables!
Try making sz a known vector type
make a property sz = [4 4]
then try
app.sz = [C(1,1) 4];
Sorry for all the asks but I’m a very experienced C, C++ (and many other languages) programmer but this .m code is driving me crazy! Help give all kinds of useless details about setting Fonts etc but little about simple syntax for e.g. summing a column.
S = sum(A,1); does sum by columns (vs ,2 for by rows but no way to say just do column 1. Even though C is a 1×4 Can’t seem to get the scaler C(1,1) out of it properly.
C(1,1) or C(1) works in the command line, just not in my app created by app designer.
Ultimately all I really want is to make a new table of the correct size with
app.TrialsTable = table(‘Size’,sz,’VariableTypes’,{‘uint8′,’uint8′,’categorical’,’int16′}); sum, vector, table size MATLAB Answers — New Questions
Files not showing up in ‘current folder’
Hi all,
I’ve been experiencing a weird problem starting in the last 2 days. When go to a certain directory in Matlab, it doesn’t show any of the files in that directory. Moreover, using the dir() command for that directory doesn’t show any files.
I know the directory exists and there are files in it because I can access it through the normal Windows file explorer (see image below).
A few additional details. The directory I’m trying to access is a network drive. However, I can still access other network drives from Matlab and other PCs on the same network are able to view the directory in Matlab. This makes me think its something specific to Matlab on my PC with this directory (although I’m having the same issue on my personal laptop). I’m using a Windows 10 PC and Matlab 2017a.
I’ve already tried restarting matlab, my pc, disconnecting and reconnecting the drive. I have not tried reinstalling Matlab yet. Any help would be greatly appreciated!
<</matlabcentral/answers/uploaded_files/94148/currentfolder.PNG>>Hi all,
I’ve been experiencing a weird problem starting in the last 2 days. When go to a certain directory in Matlab, it doesn’t show any of the files in that directory. Moreover, using the dir() command for that directory doesn’t show any files.
I know the directory exists and there are files in it because I can access it through the normal Windows file explorer (see image below).
A few additional details. The directory I’m trying to access is a network drive. However, I can still access other network drives from Matlab and other PCs on the same network are able to view the directory in Matlab. This makes me think its something specific to Matlab on my PC with this directory (although I’m having the same issue on my personal laptop). I’m using a Windows 10 PC and Matlab 2017a.
I’ve already tried restarting matlab, my pc, disconnecting and reconnecting the drive. I have not tried reinstalling Matlab yet. Any help would be greatly appreciated!
<</matlabcentral/answers/uploaded_files/94148/currentfolder.PNG>> Hi all,
I’ve been experiencing a weird problem starting in the last 2 days. When go to a certain directory in Matlab, it doesn’t show any of the files in that directory. Moreover, using the dir() command for that directory doesn’t show any files.
I know the directory exists and there are files in it because I can access it through the normal Windows file explorer (see image below).
A few additional details. The directory I’m trying to access is a network drive. However, I can still access other network drives from Matlab and other PCs on the same network are able to view the directory in Matlab. This makes me think its something specific to Matlab on my PC with this directory (although I’m having the same issue on my personal laptop). I’m using a Windows 10 PC and Matlab 2017a.
I’ve already tried restarting matlab, my pc, disconnecting and reconnecting the drive. I have not tried reinstalling Matlab yet. Any help would be greatly appreciated!
<</matlabcentral/answers/uploaded_files/94148/currentfolder.PNG>> current folder, directory MATLAB Answers — New Questions
Code checking error in App Designer, it thinks xxxx.BackgroundColor is a scalar
I’m changing the background color to alert the user about various (async) conditions and button pressed.
if app.STOPTRIALSButton.BackgroundColor == [0.95 0.33 0.10]
app.STOPTRIALSButton.BackgroundColor = [0 1 0];
end
and I get the warning:
Unexpected use of ‘[‘ in a scalar context.
but of course colors are RGB three values, so the code runs fine.
Also while the Component browser shows (another) color as 0.65, 0.65, 0.65 that’s the wrong syntax (no commas please for easier cut and paste) and in the startup code the values are actually [0.651 0.651 0.651] so my compare failed without significant research as to why.
Finally, App Designer isn’t listed as a product below, so I can’t flag that. Just saying MATLAB is the product.I’m changing the background color to alert the user about various (async) conditions and button pressed.
if app.STOPTRIALSButton.BackgroundColor == [0.95 0.33 0.10]
app.STOPTRIALSButton.BackgroundColor = [0 1 0];
end
and I get the warning:
Unexpected use of ‘[‘ in a scalar context.
but of course colors are RGB three values, so the code runs fine.
Also while the Component browser shows (another) color as 0.65, 0.65, 0.65 that’s the wrong syntax (no commas please for easier cut and paste) and in the startup code the values are actually [0.651 0.651 0.651] so my compare failed without significant research as to why.
Finally, App Designer isn’t listed as a product below, so I can’t flag that. Just saying MATLAB is the product. I’m changing the background color to alert the user about various (async) conditions and button pressed.
if app.STOPTRIALSButton.BackgroundColor == [0.95 0.33 0.10]
app.STOPTRIALSButton.BackgroundColor = [0 1 0];
end
and I get the warning:
Unexpected use of ‘[‘ in a scalar context.
but of course colors are RGB three values, so the code runs fine.
Also while the Component browser shows (another) color as 0.65, 0.65, 0.65 that’s the wrong syntax (no commas please for easier cut and paste) and in the startup code the values are actually [0.651 0.651 0.651] so my compare failed without significant research as to why.
Finally, App Designer isn’t listed as a product below, so I can’t flag that. Just saying MATLAB is the product. backgroundcolor, scalar MATLAB Answers — New Questions
Using logicals in arrayfun
Hi,
I have two arrays:
tempA, size(10, 18)
tempB, size(1, 10) (is a column vector),
For each row in tempA, I want to extract the number of columns specified for that row by tempB. However, there are certain rows in tempB that are ‘nan’.
u = arrayfun(@(x,y) x{1}(1:y), tempA, tempB, ‘UniformOutput’, false);
Can I use logical in the arrayfun so that it automatically excludes cases that are ‘nan’?
Thank youHi,
I have two arrays:
tempA, size(10, 18)
tempB, size(1, 10) (is a column vector),
For each row in tempA, I want to extract the number of columns specified for that row by tempB. However, there are certain rows in tempB that are ‘nan’.
u = arrayfun(@(x,y) x{1}(1:y), tempA, tempB, ‘UniformOutput’, false);
Can I use logical in the arrayfun so that it automatically excludes cases that are ‘nan’?
Thank you Hi,
I have two arrays:
tempA, size(10, 18)
tempB, size(1, 10) (is a column vector),
For each row in tempA, I want to extract the number of columns specified for that row by tempB. However, there are certain rows in tempB that are ‘nan’.
u = arrayfun(@(x,y) x{1}(1:y), tempA, tempB, ‘UniformOutput’, false);
Can I use logical in the arrayfun so that it automatically excludes cases that are ‘nan’?
Thank you array function, logicals MATLAB Answers — New Questions
Find Selected button in Button Group CallBack
I have a group of 5 buttons (including a dummy one for "none"
In the callback I want to do something based on the selected button.
Here is the default start of the callback:
function ManualRewardsButtonGroupSelectionChanged(app, event)
selectedButton = app.ManualRewardsButtonGroup.SelectedObject;
So why is the selectedButton always 1? I’d like 1 to 5 so I can do the appropriate
switch app.ManualRewardsButtonGroup.NewValue % or what here?
case 1
% Give LA reward
case 2
% Give LB reward
case 3
% Give RA reward
case 4
% Give RA reward
end
Help shows that I could use event.NewValue (since selectedButton doesn’t work) but that also returns 1
https://www.mathworks.com/help/matlab/ref/matlab.ui.container.buttongroup-properties.html
Van I set each button to have a different value? (I clicked on the Value check box in the Component but no opportunity to set it. I’ve even tried assigning Tags though I don’t know what they do.
App Designer doesn’t set values and doesn’t let me do it either
% Create ManualRewardsButtonGroup
app.ManualRewardsButtonGroup = uibuttongroup(app.RewardControls);
app.ManualRewardsButtonGroup.AutoResizeChildren = ‘off’;
app.ManualRewardsButtonGroup.SelectionChangedFcn = createCallbackFcn(app, @ManualRewardsButtonGroupSelectionChanged, true);
app.ManualRewardsButtonGroup.TitlePosition = ‘centertop’;
app.ManualRewardsButtonGroup.Title = ‘Manual Rewards’;
app.ManualRewardsButtonGroup.FontSize = 10;
app.ManualRewardsButtonGroup.Position = [38 6 190 95];
% Create Rew_ALeftButton
app.Rew_ALeftButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.Rew_ALeftButton.Tag = ‘1’;
app.Rew_ALeftButton.Text = ‘Rew_A Left’;
app.Rew_ALeftButton.FontSize = 10;
app.Rew_ALeftButton.Position = [11 49 73 22];
% Create Rew_ARightButton
app.Rew_ARightButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.Rew_ARightButton.Tag = ‘2’;
app.Rew_ARightButton.Text = ‘Rew_A Right’;
app.Rew_ARightButton.FontSize = 10;
app.Rew_ARightButton.Position = [101 49 80 22];
% Create Rew_BLeftButton
app.Rew_BLeftButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.Rew_BLeftButton.Tag = ‘3’;
app.Rew_BLeftButton.Text = ‘Rew_B Left’;
app.Rew_BLeftButton.FontSize = 10;
app.Rew_BLeftButton.Position = [11 27 74 22];
% Create Rew_BRightButton
app.Rew_BRightButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.Rew_BRightButton.Tag = ‘4’;
app.Rew_BRightButton.Text = ‘Rew_B Right’;
app.Rew_BRightButton.FontSize = 10;
app.Rew_BRightButton.Position = [101 27 80 22];
app.Rew_BRightButton.Value = true;
% Create OffButton
app.OffButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.OffButton.Text = ‘Off’;
app.OffButton.FontSize = 10;
app.OffButton.Position = [85 5 35 22];% Create ManualRewardsButtonGroup
app.ManualRewardsButtonGroup = uibuttongroup(app.RewardControls);
app.ManualRewardsButtonGroup.AutoResizeChildren = ‘off’;
app.ManualRewardsButtonGroup.SelectionChangedFcn = createCallbackFcn(app, @ManualRewardsButtonGroupSelectionChanged, true);
app.ManualRewardsButtonGroup.TitlePosition = ‘centertop’;
app.ManualRewardsButtonGroup.Title = ‘Manual Rewards’;
app.ManualRewardsButtonGroup.FontSize = 10;
app.ManualRewardsButtonGroup.Position = [38 6 190 95];
% Create Rew_ALeftButton
app.Rew_ALeftButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.Rew_ALeftButton.Tag = ‘1’;
app.Rew_ALeftButton.Text = ‘Rew_A Left’;
app.Rew_ALeftButton.FontSize = 10;
app.Rew_ALeftButton.Position = [11 49 73 22];
% Create Rew_ARightButton
app.Rew_ARightButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.Rew_ARightButton.Tag = ‘2’;
app.Rew_ARightButton.Text = ‘Rew_A Right’;
app.Rew_ARightButton.FontSize = 10;
app.Rew_ARightButton.Position = [101 49 80 22];
% Create Rew_BLeftButton
app.Rew_BLeftButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.Rew_BLeftButton.Tag = ‘3’;
app.Rew_BLeftButton.Text = ‘Rew_B Left’;
app.Rew_BLeftButton.FontSize = 10;
app.Rew_BLeftButton.Position = [11 27 74 22];
% Create Rew_BRightButton
app.Rew_BRightButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.Rew_BRightButton.Tag = ‘4’;
app.Rew_BRightButton.Text = ‘Rew_B Right’;
app.Rew_BRightButton.FontSize = 10;
app.Rew_BRightButton.Position = [101 27 80 22];
app.Rew_BRightButton.Value = true;
% Create OffButton
app.OffButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.OffButton.Text = ‘Off’;
app.OffButton.FontSize = 10;
app.OffButton.Position = [85 5 35 22];I have a group of 5 buttons (including a dummy one for "none"
In the callback I want to do something based on the selected button.
Here is the default start of the callback:
function ManualRewardsButtonGroupSelectionChanged(app, event)
selectedButton = app.ManualRewardsButtonGroup.SelectedObject;
So why is the selectedButton always 1? I’d like 1 to 5 so I can do the appropriate
switch app.ManualRewardsButtonGroup.NewValue % or what here?
case 1
% Give LA reward
case 2
% Give LB reward
case 3
% Give RA reward
case 4
% Give RA reward
end
Help shows that I could use event.NewValue (since selectedButton doesn’t work) but that also returns 1
https://www.mathworks.com/help/matlab/ref/matlab.ui.container.buttongroup-properties.html
Van I set each button to have a different value? (I clicked on the Value check box in the Component but no opportunity to set it. I’ve even tried assigning Tags though I don’t know what they do.
App Designer doesn’t set values and doesn’t let me do it either
% Create ManualRewardsButtonGroup
app.ManualRewardsButtonGroup = uibuttongroup(app.RewardControls);
app.ManualRewardsButtonGroup.AutoResizeChildren = ‘off’;
app.ManualRewardsButtonGroup.SelectionChangedFcn = createCallbackFcn(app, @ManualRewardsButtonGroupSelectionChanged, true);
app.ManualRewardsButtonGroup.TitlePosition = ‘centertop’;
app.ManualRewardsButtonGroup.Title = ‘Manual Rewards’;
app.ManualRewardsButtonGroup.FontSize = 10;
app.ManualRewardsButtonGroup.Position = [38 6 190 95];
% Create Rew_ALeftButton
app.Rew_ALeftButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.Rew_ALeftButton.Tag = ‘1’;
app.Rew_ALeftButton.Text = ‘Rew_A Left’;
app.Rew_ALeftButton.FontSize = 10;
app.Rew_ALeftButton.Position = [11 49 73 22];
% Create Rew_ARightButton
app.Rew_ARightButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.Rew_ARightButton.Tag = ‘2’;
app.Rew_ARightButton.Text = ‘Rew_A Right’;
app.Rew_ARightButton.FontSize = 10;
app.Rew_ARightButton.Position = [101 49 80 22];
% Create Rew_BLeftButton
app.Rew_BLeftButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.Rew_BLeftButton.Tag = ‘3’;
app.Rew_BLeftButton.Text = ‘Rew_B Left’;
app.Rew_BLeftButton.FontSize = 10;
app.Rew_BLeftButton.Position = [11 27 74 22];
% Create Rew_BRightButton
app.Rew_BRightButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.Rew_BRightButton.Tag = ‘4’;
app.Rew_BRightButton.Text = ‘Rew_B Right’;
app.Rew_BRightButton.FontSize = 10;
app.Rew_BRightButton.Position = [101 27 80 22];
app.Rew_BRightButton.Value = true;
% Create OffButton
app.OffButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.OffButton.Text = ‘Off’;
app.OffButton.FontSize = 10;
app.OffButton.Position = [85 5 35 22];% Create ManualRewardsButtonGroup
app.ManualRewardsButtonGroup = uibuttongroup(app.RewardControls);
app.ManualRewardsButtonGroup.AutoResizeChildren = ‘off’;
app.ManualRewardsButtonGroup.SelectionChangedFcn = createCallbackFcn(app, @ManualRewardsButtonGroupSelectionChanged, true);
app.ManualRewardsButtonGroup.TitlePosition = ‘centertop’;
app.ManualRewardsButtonGroup.Title = ‘Manual Rewards’;
app.ManualRewardsButtonGroup.FontSize = 10;
app.ManualRewardsButtonGroup.Position = [38 6 190 95];
% Create Rew_ALeftButton
app.Rew_ALeftButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.Rew_ALeftButton.Tag = ‘1’;
app.Rew_ALeftButton.Text = ‘Rew_A Left’;
app.Rew_ALeftButton.FontSize = 10;
app.Rew_ALeftButton.Position = [11 49 73 22];
% Create Rew_ARightButton
app.Rew_ARightButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.Rew_ARightButton.Tag = ‘2’;
app.Rew_ARightButton.Text = ‘Rew_A Right’;
app.Rew_ARightButton.FontSize = 10;
app.Rew_ARightButton.Position = [101 49 80 22];
% Create Rew_BLeftButton
app.Rew_BLeftButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.Rew_BLeftButton.Tag = ‘3’;
app.Rew_BLeftButton.Text = ‘Rew_B Left’;
app.Rew_BLeftButton.FontSize = 10;
app.Rew_BLeftButton.Position = [11 27 74 22];
% Create Rew_BRightButton
app.Rew_BRightButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.Rew_BRightButton.Tag = ‘4’;
app.Rew_BRightButton.Text = ‘Rew_B Right’;
app.Rew_BRightButton.FontSize = 10;
app.Rew_BRightButton.Position = [101 27 80 22];
app.Rew_BRightButton.Value = true;
% Create OffButton
app.OffButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.OffButton.Text = ‘Off’;
app.OffButton.FontSize = 10;
app.OffButton.Position = [85 5 35 22]; I have a group of 5 buttons (including a dummy one for "none"
In the callback I want to do something based on the selected button.
Here is the default start of the callback:
function ManualRewardsButtonGroupSelectionChanged(app, event)
selectedButton = app.ManualRewardsButtonGroup.SelectedObject;
So why is the selectedButton always 1? I’d like 1 to 5 so I can do the appropriate
switch app.ManualRewardsButtonGroup.NewValue % or what here?
case 1
% Give LA reward
case 2
% Give LB reward
case 3
% Give RA reward
case 4
% Give RA reward
end
Help shows that I could use event.NewValue (since selectedButton doesn’t work) but that also returns 1
https://www.mathworks.com/help/matlab/ref/matlab.ui.container.buttongroup-properties.html
Van I set each button to have a different value? (I clicked on the Value check box in the Component but no opportunity to set it. I’ve even tried assigning Tags though I don’t know what they do.
App Designer doesn’t set values and doesn’t let me do it either
% Create ManualRewardsButtonGroup
app.ManualRewardsButtonGroup = uibuttongroup(app.RewardControls);
app.ManualRewardsButtonGroup.AutoResizeChildren = ‘off’;
app.ManualRewardsButtonGroup.SelectionChangedFcn = createCallbackFcn(app, @ManualRewardsButtonGroupSelectionChanged, true);
app.ManualRewardsButtonGroup.TitlePosition = ‘centertop’;
app.ManualRewardsButtonGroup.Title = ‘Manual Rewards’;
app.ManualRewardsButtonGroup.FontSize = 10;
app.ManualRewardsButtonGroup.Position = [38 6 190 95];
% Create Rew_ALeftButton
app.Rew_ALeftButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.Rew_ALeftButton.Tag = ‘1’;
app.Rew_ALeftButton.Text = ‘Rew_A Left’;
app.Rew_ALeftButton.FontSize = 10;
app.Rew_ALeftButton.Position = [11 49 73 22];
% Create Rew_ARightButton
app.Rew_ARightButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.Rew_ARightButton.Tag = ‘2’;
app.Rew_ARightButton.Text = ‘Rew_A Right’;
app.Rew_ARightButton.FontSize = 10;
app.Rew_ARightButton.Position = [101 49 80 22];
% Create Rew_BLeftButton
app.Rew_BLeftButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.Rew_BLeftButton.Tag = ‘3’;
app.Rew_BLeftButton.Text = ‘Rew_B Left’;
app.Rew_BLeftButton.FontSize = 10;
app.Rew_BLeftButton.Position = [11 27 74 22];
% Create Rew_BRightButton
app.Rew_BRightButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.Rew_BRightButton.Tag = ‘4’;
app.Rew_BRightButton.Text = ‘Rew_B Right’;
app.Rew_BRightButton.FontSize = 10;
app.Rew_BRightButton.Position = [101 27 80 22];
app.Rew_BRightButton.Value = true;
% Create OffButton
app.OffButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.OffButton.Text = ‘Off’;
app.OffButton.FontSize = 10;
app.OffButton.Position = [85 5 35 22];% Create ManualRewardsButtonGroup
app.ManualRewardsButtonGroup = uibuttongroup(app.RewardControls);
app.ManualRewardsButtonGroup.AutoResizeChildren = ‘off’;
app.ManualRewardsButtonGroup.SelectionChangedFcn = createCallbackFcn(app, @ManualRewardsButtonGroupSelectionChanged, true);
app.ManualRewardsButtonGroup.TitlePosition = ‘centertop’;
app.ManualRewardsButtonGroup.Title = ‘Manual Rewards’;
app.ManualRewardsButtonGroup.FontSize = 10;
app.ManualRewardsButtonGroup.Position = [38 6 190 95];
% Create Rew_ALeftButton
app.Rew_ALeftButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.Rew_ALeftButton.Tag = ‘1’;
app.Rew_ALeftButton.Text = ‘Rew_A Left’;
app.Rew_ALeftButton.FontSize = 10;
app.Rew_ALeftButton.Position = [11 49 73 22];
% Create Rew_ARightButton
app.Rew_ARightButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.Rew_ARightButton.Tag = ‘2’;
app.Rew_ARightButton.Text = ‘Rew_A Right’;
app.Rew_ARightButton.FontSize = 10;
app.Rew_ARightButton.Position = [101 49 80 22];
% Create Rew_BLeftButton
app.Rew_BLeftButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.Rew_BLeftButton.Tag = ‘3’;
app.Rew_BLeftButton.Text = ‘Rew_B Left’;
app.Rew_BLeftButton.FontSize = 10;
app.Rew_BLeftButton.Position = [11 27 74 22];
% Create Rew_BRightButton
app.Rew_BRightButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.Rew_BRightButton.Tag = ‘4’;
app.Rew_BRightButton.Text = ‘Rew_B Right’;
app.Rew_BRightButton.FontSize = 10;
app.Rew_BRightButton.Position = [101 27 80 22];
app.Rew_BRightButton.Value = true;
% Create OffButton
app.OffButton = uiradiobutton(app.ManualRewardsButtonGroup);
app.OffButton.Text = ‘Off’;
app.OffButton.FontSize = 10;
app.OffButton.Position = [85 5 35 22]; buttongroup, selectedbutton MATLAB Answers — New Questions
How to explain an ANN graph?
Hello, I’m trying to interpret an ANN graph for a paper, but I’m not sure where to start. Should I explain the detailed computations for each data point, or is there a general approach I can use to highlight the overall differences between the two groups? How do I know if it’s considered a good result? Here’s a sample figure
y=root mean square error, x=number of neurons
y=displacement, x=time pointsHello, I’m trying to interpret an ANN graph for a paper, but I’m not sure where to start. Should I explain the detailed computations for each data point, or is there a general approach I can use to highlight the overall differences between the two groups? How do I know if it’s considered a good result? Here’s a sample figure
y=root mean square error, x=number of neurons
y=displacement, x=time points Hello, I’m trying to interpret an ANN graph for a paper, but I’m not sure where to start. Should I explain the detailed computations for each data point, or is there a general approach I can use to highlight the overall differences between the two groups? How do I know if it’s considered a good result? Here’s a sample figure
y=root mean square error, x=number of neurons
y=displacement, x=time points graph, neural network MATLAB Answers — New Questions
Plotted data changes when applying custom colormap
Question:
I am working with a very specific custom color map, that i apply to a matrix using imagesc(). When plotting my data with a built in colormap, everything plots as expected. When im using my own colormap, the image itself plots and the colormap works wonderfully. However: The y-coordinates of my matrix shift! The x coordinates are unaffected by this. Everything is plotted within the same figure, the only difference between the figures is the colormap() command. I hope this is a well known problem, however my internet search didnt resolve the issue.
Thanks in advance for anyone who answers!
Appendix:
Plot with built in colormap: Note that the top-right most pixel of my data is at [30, 60]
imagesc(Vertical_Time_Matrix);
Plot with my Colormap: Note that the top-right most pixel of my data is at [30, 78]
imagesc(Vertical_Time_Matrix);
colormap(myColormap);
A few words regarding my colormap and the data. The data is a 220×30 matrix containing numbers ("States") from 1-28. Depending on the state a color is chosen from a color map. Hence, the colormap is 28 entries long.Question:
I am working with a very specific custom color map, that i apply to a matrix using imagesc(). When plotting my data with a built in colormap, everything plots as expected. When im using my own colormap, the image itself plots and the colormap works wonderfully. However: The y-coordinates of my matrix shift! The x coordinates are unaffected by this. Everything is plotted within the same figure, the only difference between the figures is the colormap() command. I hope this is a well known problem, however my internet search didnt resolve the issue.
Thanks in advance for anyone who answers!
Appendix:
Plot with built in colormap: Note that the top-right most pixel of my data is at [30, 60]
imagesc(Vertical_Time_Matrix);
Plot with my Colormap: Note that the top-right most pixel of my data is at [30, 78]
imagesc(Vertical_Time_Matrix);
colormap(myColormap);
A few words regarding my colormap and the data. The data is a 220×30 matrix containing numbers ("States") from 1-28. Depending on the state a color is chosen from a color map. Hence, the colormap is 28 entries long. Question:
I am working with a very specific custom color map, that i apply to a matrix using imagesc(). When plotting my data with a built in colormap, everything plots as expected. When im using my own colormap, the image itself plots and the colormap works wonderfully. However: The y-coordinates of my matrix shift! The x coordinates are unaffected by this. Everything is plotted within the same figure, the only difference between the figures is the colormap() command. I hope this is a well known problem, however my internet search didnt resolve the issue.
Thanks in advance for anyone who answers!
Appendix:
Plot with built in colormap: Note that the top-right most pixel of my data is at [30, 60]
imagesc(Vertical_Time_Matrix);
Plot with my Colormap: Note that the top-right most pixel of my data is at [30, 78]
imagesc(Vertical_Time_Matrix);
colormap(myColormap);
A few words regarding my colormap and the data. The data is a 220×30 matrix containing numbers ("States") from 1-28. Depending on the state a color is chosen from a color map. Hence, the colormap is 28 entries long. colormap, figure MATLAB Answers — New Questions
Generating data for a scheduling problem that deals with setup families.
clc
%clear all
x1 = 1:30;
x11 = 1:10;
x2 = 0.2:0.2:1;
x12 = 0.2:0.2:4;
%a = 6:100;%b = 125:25:1000;%c = 1050:50:2500;%cc = 3000:500:10000;%cc1 = 15000:5000:30000;%xx = [a b c cc cc1];%[A, B] = size(xx);%mx = max(xx);
n=input(‘n=’);
data = cell(n, 10, 3);
%families = 1:6;
familiesNumber = [2, 4, 6];
familiesSetup = 1:6;
for F = 1:3
% for j = 1:B
% n = xx(j);
% for ex = 1:10
releaseDate = randsrc(1, n, x1);
processingTime = randsrc(1, n, x11);
tf = randsrc(1, 1, x12);
ddr = randsrc(1, 1, x2);
g = sum(releaseDate);
min_due = tf * (1 – g – ddr / 2);
max_due = tf * (1 – g + ddr / 2);
if min_due < 1, min_due = 1; end % Ensure minimum due date is at least 1
if max_due < min_due, max_due = min_due + 1; end % Ensure range is valid
x = min_due:max_due;%linspace(min_due, max_due, n); % Create a range with n points
dueDate = randsrc(1, n, x); % Generate dueDate within the range
% Ensure dueDate is valid
for i = 1:n
if dueDate(i) < processingTime(i)
dueDate(i) = processingTime(i) + 1;
end
end
f = familiesNumber(F); disp(f);
m = mod(n, f);
nn = n – m;
setupTime = zeros(1, f);
for s = 1:f
setupTime = familiesSetup;
end
disp(setupTime);
nf = zeros(1, f);
if m == 0
for i = 1:f
nf(i) = n / f;
end
else
for i = 1:m
nf(i) = (nn / f) + 1;
end
for ii = m+1:f
nf(ii) = (nn / f);
end
end
disp(nf);
da = [releaseDate; processingTime; dueDate]; %disp(da);
data{n, ex, f} = da;
% end
% end
end
savefile = ‘a_data.mat’;
save(savefile, ‘data’);clc
%clear all
x1 = 1:30;
x11 = 1:10;
x2 = 0.2:0.2:1;
x12 = 0.2:0.2:4;
%a = 6:100;%b = 125:25:1000;%c = 1050:50:2500;%cc = 3000:500:10000;%cc1 = 15000:5000:30000;%xx = [a b c cc cc1];%[A, B] = size(xx);%mx = max(xx);
n=input(‘n=’);
data = cell(n, 10, 3);
%families = 1:6;
familiesNumber = [2, 4, 6];
familiesSetup = 1:6;
for F = 1:3
% for j = 1:B
% n = xx(j);
% for ex = 1:10
releaseDate = randsrc(1, n, x1);
processingTime = randsrc(1, n, x11);
tf = randsrc(1, 1, x12);
ddr = randsrc(1, 1, x2);
g = sum(releaseDate);
min_due = tf * (1 – g – ddr / 2);
max_due = tf * (1 – g + ddr / 2);
if min_due < 1, min_due = 1; end % Ensure minimum due date is at least 1
if max_due < min_due, max_due = min_due + 1; end % Ensure range is valid
x = min_due:max_due;%linspace(min_due, max_due, n); % Create a range with n points
dueDate = randsrc(1, n, x); % Generate dueDate within the range
% Ensure dueDate is valid
for i = 1:n
if dueDate(i) < processingTime(i)
dueDate(i) = processingTime(i) + 1;
end
end
f = familiesNumber(F); disp(f);
m = mod(n, f);
nn = n – m;
setupTime = zeros(1, f);
for s = 1:f
setupTime = familiesSetup;
end
disp(setupTime);
nf = zeros(1, f);
if m == 0
for i = 1:f
nf(i) = n / f;
end
else
for i = 1:m
nf(i) = (nn / f) + 1;
end
for ii = m+1:f
nf(ii) = (nn / f);
end
end
disp(nf);
da = [releaseDate; processingTime; dueDate]; %disp(da);
data{n, ex, f} = da;
% end
% end
end
savefile = ‘a_data.mat’;
save(savefile, ‘data’); clc
%clear all
x1 = 1:30;
x11 = 1:10;
x2 = 0.2:0.2:1;
x12 = 0.2:0.2:4;
%a = 6:100;%b = 125:25:1000;%c = 1050:50:2500;%cc = 3000:500:10000;%cc1 = 15000:5000:30000;%xx = [a b c cc cc1];%[A, B] = size(xx);%mx = max(xx);
n=input(‘n=’);
data = cell(n, 10, 3);
%families = 1:6;
familiesNumber = [2, 4, 6];
familiesSetup = 1:6;
for F = 1:3
% for j = 1:B
% n = xx(j);
% for ex = 1:10
releaseDate = randsrc(1, n, x1);
processingTime = randsrc(1, n, x11);
tf = randsrc(1, 1, x12);
ddr = randsrc(1, 1, x2);
g = sum(releaseDate);
min_due = tf * (1 – g – ddr / 2);
max_due = tf * (1 – g + ddr / 2);
if min_due < 1, min_due = 1; end % Ensure minimum due date is at least 1
if max_due < min_due, max_due = min_due + 1; end % Ensure range is valid
x = min_due:max_due;%linspace(min_due, max_due, n); % Create a range with n points
dueDate = randsrc(1, n, x); % Generate dueDate within the range
% Ensure dueDate is valid
for i = 1:n
if dueDate(i) < processingTime(i)
dueDate(i) = processingTime(i) + 1;
end
end
f = familiesNumber(F); disp(f);
m = mod(n, f);
nn = n – m;
setupTime = zeros(1, f);
for s = 1:f
setupTime = familiesSetup;
end
disp(setupTime);
nf = zeros(1, f);
if m == 0
for i = 1:f
nf(i) = n / f;
end
else
for i = 1:m
nf(i) = (nn / f) + 1;
end
for ii = m+1:f
nf(ii) = (nn / f);
end
end
disp(nf);
da = [releaseDate; processingTime; dueDate]; %disp(da);
data{n, ex, f} = da;
% end
% end
end
savefile = ‘a_data.mat’;
save(savefile, ‘data’); data generating, setup families, matlab, single machine scheduling problem MATLAB Answers — New Questions
How to connect point by curve instead of line in MTALB plot
Hello, guys. I have some data points. When I plot these points in Matlab, it connects data points by line. However, I want to connect these points using a curve instead of a line graph for good representation. So please suggest to me which function we should use.
Thank you.Hello, guys. I have some data points. When I plot these points in Matlab, it connects data points by line. However, I want to connect these points using a curve instead of a line graph for good representation. So please suggest to me which function we should use.
Thank you. Hello, guys. I have some data points. When I plot these points in Matlab, it connects data points by line. However, I want to connect these points using a curve instead of a line graph for good representation. So please suggest to me which function we should use.
Thank you. plotting, curve, matlab, expert MATLAB Answers — New Questions
How to downsample the 3D matrix in matlab??
Due to computational limitations, I need to downsample the 3D (1500x1500x1700) matrix by a factor of 2. The binning process should merg the 2x2x2 voxels and assign the mean intensity value of the group to the corresponding voxel in the reduced image.Due to computational limitations, I need to downsample the 3D (1500x1500x1700) matrix by a factor of 2. The binning process should merg the 2x2x2 voxels and assign the mean intensity value of the group to the corresponding voxel in the reduced image. Due to computational limitations, I need to downsample the 3D (1500x1500x1700) matrix by a factor of 2. The binning process should merg the 2x2x2 voxels and assign the mean intensity value of the group to the corresponding voxel in the reduced image. downsample, 3d matrix MATLAB Answers — New Questions
how do you develop a simulation software for drying grains using matlab
i am doing my final year project on simulation software for drying grains using mat lab but i do not have an idea on how to start on my methologyi am doing my final year project on simulation software for drying grains using mat lab but i do not have an idea on how to start on my methology i am doing my final year project on simulation software for drying grains using mat lab but i do not have an idea on how to start on my methology simulation, simulation-of-drying MATLAB Answers — New Questions