Tag Archives: matlab
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
Unrecognized function or variable ‘efficiency’
I am getting the following error but can’t figure out why.
Unrecognized function or variable ‘efficiency’.
I am using a full version of MATLAB 2024a with an academic license and all of the toolboxes installed on April 3.
I regularly use the functions from the Antenna Toolbox so I am confident that it is installed correctly. I’ve also tried copying the text from the Help Center article to make sure there weren’t any typos.
‘doc efficiency’ and ‘help efficiency’ in the command window work as expected.
Is the ‘efficiency’ function still available in 2024a? Is there any other reason why it might not be recognized?I am getting the following error but can’t figure out why.
Unrecognized function or variable ‘efficiency’.
I am using a full version of MATLAB 2024a with an academic license and all of the toolboxes installed on April 3.
I regularly use the functions from the Antenna Toolbox so I am confident that it is installed correctly. I’ve also tried copying the text from the Help Center article to make sure there weren’t any typos.
‘doc efficiency’ and ‘help efficiency’ in the command window work as expected.
Is the ‘efficiency’ function still available in 2024a? Is there any other reason why it might not be recognized? I am getting the following error but can’t figure out why.
Unrecognized function or variable ‘efficiency’.
I am using a full version of MATLAB 2024a with an academic license and all of the toolboxes installed on April 3.
I regularly use the functions from the Antenna Toolbox so I am confident that it is installed correctly. I’ve also tried copying the text from the Help Center article to make sure there weren’t any typos.
‘doc efficiency’ and ‘help efficiency’ in the command window work as expected.
Is the ‘efficiency’ function still available in 2024a? Is there any other reason why it might not be recognized? antenna toolbox, efficiency MATLAB Answers — New Questions
how to use the parameters of neural network in simulink?
Hello all,
I trained a neural network dpending on two inputs (T and p) to predect density.
Now I have the best parameters to predect density using this code:
density = model (parameters, p, T);
Plese note that I have a simulink model with the time-step is 0.001 s, the problem is how to use this parameters of the NN in the Simulink model.
input are: p and T
output is: density
time-step is 0.001
Best regards, AhmadHello all,
I trained a neural network dpending on two inputs (T and p) to predect density.
Now I have the best parameters to predect density using this code:
density = model (parameters, p, T);
Plese note that I have a simulink model with the time-step is 0.001 s, the problem is how to use this parameters of the NN in the Simulink model.
input are: p and T
output is: density
time-step is 0.001
Best regards, Ahmad Hello all,
I trained a neural network dpending on two inputs (T and p) to predect density.
Now I have the best parameters to predect density using this code:
density = model (parameters, p, T);
Plese note that I have a simulink model with the time-step is 0.001 s, the problem is how to use this parameters of the NN in the Simulink model.
input are: p and T
output is: density
time-step is 0.001
Best regards, Ahmad parameters MATLAB Answers — New Questions
How do I use live script (*.mlx) files in source control?
I would like to use the live script files with source control, what is the workflow for that?I would like to use the live script files with source control, what is the workflow for that? I would like to use the live script files with source control, what is the workflow for that? live, editor, source, control, git MATLAB Answers — New Questions
Can I use a student license if I am not currently enrolled in courses?
I have been accepted to a university for a master’s degree, and I am learning MATLAB and reviewing other courses before I start it, which will be in Fall 2025. My university has a campus-wide license. Since I was accepted into the university, I have a student email address, even though I am not currently enrolled in any classes. Would I be able to use my university’s campus access, or should I consider purchasing a home license?I have been accepted to a university for a master’s degree, and I am learning MATLAB and reviewing other courses before I start it, which will be in Fall 2025. My university has a campus-wide license. Since I was accepted into the university, I have a student email address, even though I am not currently enrolled in any classes. Would I be able to use my university’s campus access, or should I consider purchasing a home license? I have been accepted to a university for a master’s degree, and I am learning MATLAB and reviewing other courses before I start it, which will be in Fall 2025. My university has a campus-wide license. Since I was accepted into the university, I have a student email address, even though I am not currently enrolled in any classes. Would I be able to use my university’s campus access, or should I consider purchasing a home license? student license MATLAB Answers — New Questions
Spatial discretization has failed. Discretization supports only parabolic and elliptic equations, with flux term involving spatial derivative.
I tried to establish a dynamic model of the reactor using PDEs, but I couldn’t solve it. I don’t know why. The code is as follows:
In this problem, my boundary condition only has the left boundary, which is the u value and dudx when z=0. How should I write it?
function reactor_dynamic_model(obj)
global R miu comp_set A_for A_rev Ea_for Ea_rev Da lambda
Da = 1.8e-4;
lambda = 5e-4;
F_molar = obj.F_molar;
A = obj.cat_vol / obj.z0;
z0 = obj.z0;
y0 = obj.y0;
epsilon = obj.epsilon;
P = obj.P;
T0 = obj.T;
Fi0 = F_molar * y0;
Cpc = obj.Cpc;
rho = obj.rho;
epsilon = obj.epsilon;
nfe = obj.nfe;
ct0 = 0.001/pr(T0,P,y0);
Cpm0 = get_Cpm(T0,y0);
ci0=ct0.*y0;
uv0 = (epsilon*ct0.*Cpm0+Cpc*rho).*T0;
zspan = 0:z0/(nfe-1):z0;
tspan = 0:10:100;
sol = pdepe(0,@pdefun,@pdeic,@pdebc,zspan,tspan);
a=1;
function [c,f,s] = pdefun(z,t,u,dudx)
c1 = u(1);
c2 = u(2);
c3 = u(3);
c4 = u(4);
uv = u(5);
ct = c1+c2+c3+c4;
y1=c1/ct;
y2=c2/ct;
y3=c3/ct;
y4=c4/ct;
y = [y1,y2,y3,y4];
T = fzero(@solve_T_uv, T0,[],y,uv,ct);
function f0 = solve_T_uv(T,y,uv,ct)
f0 = (epsilon*ct*get_Cpm(T,y)+Cpc*rho)*T-uv;
end
dc1dz = dudx(1);
dc2dz = dudx(2);
dc3dz = dudx(3);
dc4dz = dudx(4);
dTdz = dudx(5);
x = (Fi0(1)-F_molar*y1) / (1-2*y1);
F1 = Fi0(1)-x;
F2 = Fi0(2) -3*x;
F3 = Fi0(3)+2*x;
F4 = Fi0(4);
Ft = F1+F2+F3+F4;
Cpm = get_Cpm(T, y);
h = Ft*Cpm*T;
X = (Fi0(1) – F1) / Fi0(1);
eta = get_eta(T, P, X);
r = get_r(T, P, y, eta, miu,A_for, A_rev, Ea_for, Ea_rev);
r1 = r(1);
r2 = r(2);
r3 = r(3);
r4 = r(4);
Hr = get_Hr(T, P);
c = [1;1;1;1;1];
f = [Da*dc1dz/epsilon;
Da*dc2dz/epsilon;
Da*dc3dz/epsilon;
Da*dc4dz/epsilon;
lambda*dTdz];
s = [r1/epsilon-F1/A/epsilon;
r2/epsilon-F2/A/epsilon;
r3/epsilon-F3/A/epsilon;
r4/epsilon-F4/A/epsilon;
r3*(-Hr)-h/A];
end
function u0 = pdeic(z)
class1 = PFR;
result = class1.reactor_steadystate_model(z);
T_init = result(1);
y_init = result(10:13);
ct_init = 0.001/pr(T_init,P,y_init);
ci_init = ct_init * y_init;
c1_init = ci_init(1);
c2_init = ci_init(2);
c3_init = ci_init(3);
c4_init = ci_init(4);
Cpm_init = get_Cpm(T_init,y_init);
uv_init = (epsilon*ct_init*Cpm_init+Cpc*rho)*T_init;
u0 = [c1_init;c2_init;c3_init;c4_init;uv_init];
end
function [pl,ql,pr,qr] = pdebc(zl,ul,zr,ur,t)
pl = [ul(1)-ci0(1);ul(2)-ci0(2);ul(3)-ci0(3);ul(4)-ci0(4);ul(5)-uv0];
ql = [0;0;0;0;0];
pr = [0;0;0;0;0];
qr = [0;0;0;0;0];
end
endI tried to establish a dynamic model of the reactor using PDEs, but I couldn’t solve it. I don’t know why. The code is as follows:
In this problem, my boundary condition only has the left boundary, which is the u value and dudx when z=0. How should I write it?
function reactor_dynamic_model(obj)
global R miu comp_set A_for A_rev Ea_for Ea_rev Da lambda
Da = 1.8e-4;
lambda = 5e-4;
F_molar = obj.F_molar;
A = obj.cat_vol / obj.z0;
z0 = obj.z0;
y0 = obj.y0;
epsilon = obj.epsilon;
P = obj.P;
T0 = obj.T;
Fi0 = F_molar * y0;
Cpc = obj.Cpc;
rho = obj.rho;
epsilon = obj.epsilon;
nfe = obj.nfe;
ct0 = 0.001/pr(T0,P,y0);
Cpm0 = get_Cpm(T0,y0);
ci0=ct0.*y0;
uv0 = (epsilon*ct0.*Cpm0+Cpc*rho).*T0;
zspan = 0:z0/(nfe-1):z0;
tspan = 0:10:100;
sol = pdepe(0,@pdefun,@pdeic,@pdebc,zspan,tspan);
a=1;
function [c,f,s] = pdefun(z,t,u,dudx)
c1 = u(1);
c2 = u(2);
c3 = u(3);
c4 = u(4);
uv = u(5);
ct = c1+c2+c3+c4;
y1=c1/ct;
y2=c2/ct;
y3=c3/ct;
y4=c4/ct;
y = [y1,y2,y3,y4];
T = fzero(@solve_T_uv, T0,[],y,uv,ct);
function f0 = solve_T_uv(T,y,uv,ct)
f0 = (epsilon*ct*get_Cpm(T,y)+Cpc*rho)*T-uv;
end
dc1dz = dudx(1);
dc2dz = dudx(2);
dc3dz = dudx(3);
dc4dz = dudx(4);
dTdz = dudx(5);
x = (Fi0(1)-F_molar*y1) / (1-2*y1);
F1 = Fi0(1)-x;
F2 = Fi0(2) -3*x;
F3 = Fi0(3)+2*x;
F4 = Fi0(4);
Ft = F1+F2+F3+F4;
Cpm = get_Cpm(T, y);
h = Ft*Cpm*T;
X = (Fi0(1) – F1) / Fi0(1);
eta = get_eta(T, P, X);
r = get_r(T, P, y, eta, miu,A_for, A_rev, Ea_for, Ea_rev);
r1 = r(1);
r2 = r(2);
r3 = r(3);
r4 = r(4);
Hr = get_Hr(T, P);
c = [1;1;1;1;1];
f = [Da*dc1dz/epsilon;
Da*dc2dz/epsilon;
Da*dc3dz/epsilon;
Da*dc4dz/epsilon;
lambda*dTdz];
s = [r1/epsilon-F1/A/epsilon;
r2/epsilon-F2/A/epsilon;
r3/epsilon-F3/A/epsilon;
r4/epsilon-F4/A/epsilon;
r3*(-Hr)-h/A];
end
function u0 = pdeic(z)
class1 = PFR;
result = class1.reactor_steadystate_model(z);
T_init = result(1);
y_init = result(10:13);
ct_init = 0.001/pr(T_init,P,y_init);
ci_init = ct_init * y_init;
c1_init = ci_init(1);
c2_init = ci_init(2);
c3_init = ci_init(3);
c4_init = ci_init(4);
Cpm_init = get_Cpm(T_init,y_init);
uv_init = (epsilon*ct_init*Cpm_init+Cpc*rho)*T_init;
u0 = [c1_init;c2_init;c3_init;c4_init;uv_init];
end
function [pl,ql,pr,qr] = pdebc(zl,ul,zr,ur,t)
pl = [ul(1)-ci0(1);ul(2)-ci0(2);ul(3)-ci0(3);ul(4)-ci0(4);ul(5)-uv0];
ql = [0;0;0;0;0];
pr = [0;0;0;0;0];
qr = [0;0;0;0;0];
end
end I tried to establish a dynamic model of the reactor using PDEs, but I couldn’t solve it. I don’t know why. The code is as follows:
In this problem, my boundary condition only has the left boundary, which is the u value and dudx when z=0. How should I write it?
function reactor_dynamic_model(obj)
global R miu comp_set A_for A_rev Ea_for Ea_rev Da lambda
Da = 1.8e-4;
lambda = 5e-4;
F_molar = obj.F_molar;
A = obj.cat_vol / obj.z0;
z0 = obj.z0;
y0 = obj.y0;
epsilon = obj.epsilon;
P = obj.P;
T0 = obj.T;
Fi0 = F_molar * y0;
Cpc = obj.Cpc;
rho = obj.rho;
epsilon = obj.epsilon;
nfe = obj.nfe;
ct0 = 0.001/pr(T0,P,y0);
Cpm0 = get_Cpm(T0,y0);
ci0=ct0.*y0;
uv0 = (epsilon*ct0.*Cpm0+Cpc*rho).*T0;
zspan = 0:z0/(nfe-1):z0;
tspan = 0:10:100;
sol = pdepe(0,@pdefun,@pdeic,@pdebc,zspan,tspan);
a=1;
function [c,f,s] = pdefun(z,t,u,dudx)
c1 = u(1);
c2 = u(2);
c3 = u(3);
c4 = u(4);
uv = u(5);
ct = c1+c2+c3+c4;
y1=c1/ct;
y2=c2/ct;
y3=c3/ct;
y4=c4/ct;
y = [y1,y2,y3,y4];
T = fzero(@solve_T_uv, T0,[],y,uv,ct);
function f0 = solve_T_uv(T,y,uv,ct)
f0 = (epsilon*ct*get_Cpm(T,y)+Cpc*rho)*T-uv;
end
dc1dz = dudx(1);
dc2dz = dudx(2);
dc3dz = dudx(3);
dc4dz = dudx(4);
dTdz = dudx(5);
x = (Fi0(1)-F_molar*y1) / (1-2*y1);
F1 = Fi0(1)-x;
F2 = Fi0(2) -3*x;
F3 = Fi0(3)+2*x;
F4 = Fi0(4);
Ft = F1+F2+F3+F4;
Cpm = get_Cpm(T, y);
h = Ft*Cpm*T;
X = (Fi0(1) – F1) / Fi0(1);
eta = get_eta(T, P, X);
r = get_r(T, P, y, eta, miu,A_for, A_rev, Ea_for, Ea_rev);
r1 = r(1);
r2 = r(2);
r3 = r(3);
r4 = r(4);
Hr = get_Hr(T, P);
c = [1;1;1;1;1];
f = [Da*dc1dz/epsilon;
Da*dc2dz/epsilon;
Da*dc3dz/epsilon;
Da*dc4dz/epsilon;
lambda*dTdz];
s = [r1/epsilon-F1/A/epsilon;
r2/epsilon-F2/A/epsilon;
r3/epsilon-F3/A/epsilon;
r4/epsilon-F4/A/epsilon;
r3*(-Hr)-h/A];
end
function u0 = pdeic(z)
class1 = PFR;
result = class1.reactor_steadystate_model(z);
T_init = result(1);
y_init = result(10:13);
ct_init = 0.001/pr(T_init,P,y_init);
ci_init = ct_init * y_init;
c1_init = ci_init(1);
c2_init = ci_init(2);
c3_init = ci_init(3);
c4_init = ci_init(4);
Cpm_init = get_Cpm(T_init,y_init);
uv_init = (epsilon*ct_init*Cpm_init+Cpc*rho)*T_init;
u0 = [c1_init;c2_init;c3_init;c4_init;uv_init];
end
function [pl,ql,pr,qr] = pdebc(zl,ul,zr,ur,t)
pl = [ul(1)-ci0(1);ul(2)-ci0(2);ul(3)-ci0(3);ul(4)-ci0(4);ul(5)-uv0];
ql = [0;0;0;0;0];
pr = [0;0;0;0;0];
qr = [0;0;0;0;0];
end
end pdepe, boundary condition, spatial discretization, elliptic, pdes, initial condition, pfr, dynamic model, ammonia synthesis MATLAB Answers — New Questions
y-Label cut off by exportgraphics()
The description of the function exportgraphics says, that it produces a tightly cropped image. In my case it produces a tightly cropped PDF which is unfortunately a little bit too tight at the y-label. I tried rearranging the figure within the window, but exportgraphics does not change its output (which is the intended functionality). Unfortunately, in my case, this leads to a cut image.
The code:
set(groot,’defaultAxesFontName’,’PT Sans’)
p = figure(‘Position’, [455,503,879,400]);
ylabel(‘Label Example: i C’, ‘FontWeight’, ‘bold’)
set(gca, ‘FontSize’, 14)
exportgraphics(p,’label_example.pdf’,’BackgroundColor’,’none’,’ContentType’,’vector’);
produces a slightly cut off y-label as you can see in this picture:
The large C as well as the small i are cut off at the top. The font ‘PT Sans’ is only needed to produce the exact image, but the problem is also happening with other fonts. At the other borders of my figure exportgraphics adds a small white space, as I would expect. This only happens for the y-label.
If you need further information, please comment and I will try to give it to you as soon as possible. Thanks in advance for the help.
Best regards
StefanThe description of the function exportgraphics says, that it produces a tightly cropped image. In my case it produces a tightly cropped PDF which is unfortunately a little bit too tight at the y-label. I tried rearranging the figure within the window, but exportgraphics does not change its output (which is the intended functionality). Unfortunately, in my case, this leads to a cut image.
The code:
set(groot,’defaultAxesFontName’,’PT Sans’)
p = figure(‘Position’, [455,503,879,400]);
ylabel(‘Label Example: i C’, ‘FontWeight’, ‘bold’)
set(gca, ‘FontSize’, 14)
exportgraphics(p,’label_example.pdf’,’BackgroundColor’,’none’,’ContentType’,’vector’);
produces a slightly cut off y-label as you can see in this picture:
The large C as well as the small i are cut off at the top. The font ‘PT Sans’ is only needed to produce the exact image, but the problem is also happening with other fonts. At the other borders of my figure exportgraphics adds a small white space, as I would expect. This only happens for the y-label.
If you need further information, please comment and I will try to give it to you as soon as possible. Thanks in advance for the help.
Best regards
Stefan The description of the function exportgraphics says, that it produces a tightly cropped image. In my case it produces a tightly cropped PDF which is unfortunately a little bit too tight at the y-label. I tried rearranging the figure within the window, but exportgraphics does not change its output (which is the intended functionality). Unfortunately, in my case, this leads to a cut image.
The code:
set(groot,’defaultAxesFontName’,’PT Sans’)
p = figure(‘Position’, [455,503,879,400]);
ylabel(‘Label Example: i C’, ‘FontWeight’, ‘bold’)
set(gca, ‘FontSize’, 14)
exportgraphics(p,’label_example.pdf’,’BackgroundColor’,’none’,’ContentType’,’vector’);
produces a slightly cut off y-label as you can see in this picture:
The large C as well as the small i are cut off at the top. The font ‘PT Sans’ is only needed to produce the exact image, but the problem is also happening with other fonts. At the other borders of my figure exportgraphics adds a small white space, as I would expect. This only happens for the y-label.
If you need further information, please comment and I will try to give it to you as soon as possible. Thanks in advance for the help.
Best regards
Stefan exportgraphics MATLAB Answers — New Questions
accelerate 3D matrix multiptication using bsxfun
Hi
I have athe following code
it takes forever to run, and disable my CPU in the prosess…
I’m looking for a way to make it run better (GPU is also an option)
norm_mode is 256×256 double matrix (X,Y) image
fields is 16384×15 complex double matrix (time,mode)
in the end’ I need a 3D matrix take each norm_mode image will also be a function for time and suming all the modes- 3D matrix 256x256x16384
that is the total_field
do you have any sugestions on how to make it run better?
Thanks,
Barak
function total_field = BuildSpatialField(fields,fiber, sim, others)
total_field = zeros( newSize, newSize, length(others.t) ); % total_field(X,Y,t)
h = waitbar(0, ‘calculate field…’);
for ii=1:others.modes
norm_mode = % load new phi
tmp = bsxfun(@times, norm_mode, reshape(fields(:,ii),1,1,[]));
total_field = total_field + tmp;
waitbar(ii/others.modes, h, [‘mode ‘ num2str(ii) ‘ from ‘ num2str(others.modes)]);
end
close(h);
endHi
I have athe following code
it takes forever to run, and disable my CPU in the prosess…
I’m looking for a way to make it run better (GPU is also an option)
norm_mode is 256×256 double matrix (X,Y) image
fields is 16384×15 complex double matrix (time,mode)
in the end’ I need a 3D matrix take each norm_mode image will also be a function for time and suming all the modes- 3D matrix 256x256x16384
that is the total_field
do you have any sugestions on how to make it run better?
Thanks,
Barak
function total_field = BuildSpatialField(fields,fiber, sim, others)
total_field = zeros( newSize, newSize, length(others.t) ); % total_field(X,Y,t)
h = waitbar(0, ‘calculate field…’);
for ii=1:others.modes
norm_mode = % load new phi
tmp = bsxfun(@times, norm_mode, reshape(fields(:,ii),1,1,[]));
total_field = total_field + tmp;
waitbar(ii/others.modes, h, [‘mode ‘ num2str(ii) ‘ from ‘ num2str(others.modes)]);
end
close(h);
end Hi
I have athe following code
it takes forever to run, and disable my CPU in the prosess…
I’m looking for a way to make it run better (GPU is also an option)
norm_mode is 256×256 double matrix (X,Y) image
fields is 16384×15 complex double matrix (time,mode)
in the end’ I need a 3D matrix take each norm_mode image will also be a function for time and suming all the modes- 3D matrix 256x256x16384
that is the total_field
do you have any sugestions on how to make it run better?
Thanks,
Barak
function total_field = BuildSpatialField(fields,fiber, sim, others)
total_field = zeros( newSize, newSize, length(others.t) ); % total_field(X,Y,t)
h = waitbar(0, ‘calculate field…’);
for ii=1:others.modes
norm_mode = % load new phi
tmp = bsxfun(@times, norm_mode, reshape(fields(:,ii),1,1,[]));
total_field = total_field + tmp;
waitbar(ii/others.modes, h, [‘mode ‘ num2str(ii) ‘ from ‘ num2str(others.modes)]);
end
close(h);
end bsxfun, acceleration MATLAB Answers — New Questions
how to close an UIFigure from a second app
Hello !
Using app designer, I’ve created an application (app1) which, when I press a button (button1), opens a second application (app2). In app1, I also have a second button (button2) which, when pressed, opens a third app (app3). In app3, I have a button which, when pressed, executes a code and when it’s finished, I’d like the code to close not only app3 but also app2. I’ve managed to close app3, but my problem is with closing app2.
In app1 and app3, I declared the app2 handle (app2handle) as a public property. However, in app3, when I use the line:
delete(app.app2handle);
app2 doesn’t close.
The same line of code in app1, closes app2.
How can I do this?Hello !
Using app designer, I’ve created an application (app1) which, when I press a button (button1), opens a second application (app2). In app1, I also have a second button (button2) which, when pressed, opens a third app (app3). In app3, I have a button which, when pressed, executes a code and when it’s finished, I’d like the code to close not only app3 but also app2. I’ve managed to close app3, but my problem is with closing app2.
In app1 and app3, I declared the app2 handle (app2handle) as a public property. However, in app3, when I use the line:
delete(app.app2handle);
app2 doesn’t close.
The same line of code in app1, closes app2.
How can I do this? Hello !
Using app designer, I’ve created an application (app1) which, when I press a button (button1), opens a second application (app2). In app1, I also have a second button (button2) which, when pressed, opens a third app (app3). In app3, I have a button which, when pressed, executes a code and when it’s finished, I’d like the code to close not only app3 but also app2. I’ve managed to close app3, but my problem is with closing app2.
In app1 and app3, I declared the app2 handle (app2handle) as a public property. However, in app3, when I use the line:
delete(app.app2handle);
app2 doesn’t close.
The same line of code in app1, closes app2.
How can I do this? appdesigner MATLAB Answers — New Questions
How to solve this differential equation? I got ”Warning: Unable to find symbolic solution.” error. What am I missing ?
T=200;
W=37.65;
W=17.4;
FC=400/240/2;
d0=0.005;
C=0.16099608;
curve=10;
hmax=30e3;
g0=9.8;
R=315000;
syms H(t)
ode =diff(H,t,2) == -d0*(exp(-curve*H/hmax)-exp(-curve))*C*diff(H,t,1)^2/(W-t*FC)*9.8-g0/(1+H/R)^2+T/(W-t*FC)*9.8;
hSol(t) = dsolve(ode)T=200;
W=37.65;
W=17.4;
FC=400/240/2;
d0=0.005;
C=0.16099608;
curve=10;
hmax=30e3;
g0=9.8;
R=315000;
syms H(t)
ode =diff(H,t,2) == -d0*(exp(-curve*H/hmax)-exp(-curve))*C*diff(H,t,1)^2/(W-t*FC)*9.8-g0/(1+H/R)^2+T/(W-t*FC)*9.8;
hSol(t) = dsolve(ode) T=200;
W=37.65;
W=17.4;
FC=400/240/2;
d0=0.005;
C=0.16099608;
curve=10;
hmax=30e3;
g0=9.8;
R=315000;
syms H(t)
ode =diff(H,t,2) == -d0*(exp(-curve*H/hmax)-exp(-curve))*C*diff(H,t,1)^2/(W-t*FC)*9.8-g0/(1+H/R)^2+T/(W-t*FC)*9.8;
hSol(t) = dsolve(ode) differential equations, code MATLAB Answers — New Questions
Boundary Extraction Issue Using Image Restoration Techniques
Hi, I’m working on extracting boundary points from an image, but the output appears inverted. How can I correctly extract boundary points so the image restoration matches the original orientation? Here’s my current MATLAB code:
clear all;
img = imread(‘parol.png’); % Replace with your image file
grayImg = rgb2gray(img); % Convert to grayscale
bwImg = imbinarize(grayImg); % Convert to binary image
% Invert the binary image if necessary
bwImg = imcomplement(bwImg);
% Fill holes in the binary image
bwImg = imfill(bwImg, ‘holes’);
% Get boundary points
boundaries = bwboundaries(bwImg);
% Extract the main boundary points
boundaryPoints = boundaries{1};
% Plot the boundary points
figure;
subplot(1,2,1)
imshow(img);
subplot(1,2,2)
plot(boundaryPoints(:,2), boundaryPoints(:,1), ‘r’, ‘LineWidth’, 2);
hold off;
daspect([1 1 1]);
Thanks!Hi, I’m working on extracting boundary points from an image, but the output appears inverted. How can I correctly extract boundary points so the image restoration matches the original orientation? Here’s my current MATLAB code:
clear all;
img = imread(‘parol.png’); % Replace with your image file
grayImg = rgb2gray(img); % Convert to grayscale
bwImg = imbinarize(grayImg); % Convert to binary image
% Invert the binary image if necessary
bwImg = imcomplement(bwImg);
% Fill holes in the binary image
bwImg = imfill(bwImg, ‘holes’);
% Get boundary points
boundaries = bwboundaries(bwImg);
% Extract the main boundary points
boundaryPoints = boundaries{1};
% Plot the boundary points
figure;
subplot(1,2,1)
imshow(img);
subplot(1,2,2)
plot(boundaryPoints(:,2), boundaryPoints(:,1), ‘r’, ‘LineWidth’, 2);
hold off;
daspect([1 1 1]);
Thanks! Hi, I’m working on extracting boundary points from an image, but the output appears inverted. How can I correctly extract boundary points so the image restoration matches the original orientation? Here’s my current MATLAB code:
clear all;
img = imread(‘parol.png’); % Replace with your image file
grayImg = rgb2gray(img); % Convert to grayscale
bwImg = imbinarize(grayImg); % Convert to binary image
% Invert the binary image if necessary
bwImg = imcomplement(bwImg);
% Fill holes in the binary image
bwImg = imfill(bwImg, ‘holes’);
% Get boundary points
boundaries = bwboundaries(bwImg);
% Extract the main boundary points
boundaryPoints = boundaries{1};
% Plot the boundary points
figure;
subplot(1,2,1)
imshow(img);
subplot(1,2,2)
plot(boundaryPoints(:,2), boundaryPoints(:,1), ‘r’, ‘LineWidth’, 2);
hold off;
daspect([1 1 1]);
Thanks! image processing, boundary point MATLAB Answers — New Questions