Tag Archives: matlab
clustering the random numbers
Hi, Im having 10 number of ones and 30 zeros places in the random position in 1×40 matrix. now i need to cluster 1’s side by side (adjacent 1’s) among 10 1’s.The max number of adjacent ones is nmax? So if nmax is 5, then maximum number of adjacent ones will be 5.Thank YouHi, Im having 10 number of ones and 30 zeros places in the random position in 1×40 matrix. now i need to cluster 1’s side by side (adjacent 1’s) among 10 1’s.The max number of adjacent ones is nmax? So if nmax is 5, then maximum number of adjacent ones will be 5.Thank You Hi, Im having 10 number of ones and 30 zeros places in the random position in 1×40 matrix. now i need to cluster 1’s side by side (adjacent 1’s) among 10 1’s.The max number of adjacent ones is nmax? So if nmax is 5, then maximum number of adjacent ones will be 5.Thank You random number generator, matlab coder MATLAB Answers — New Questions
How do I access the port width, data types, and dimensions individually for the blocks in my Simulink model from the MATLAB command line?
I would like to access the port width, data types, and dimensions individually for the blocks in my Simulink model from the MATLAB command line. I would like this to work with my bus signals as well.I would like to access the port width, data types, and dimensions individually for the blocks in my Simulink model from the MATLAB command line. I would like this to work with my bus signals as well. I would like to access the port width, data types, and dimensions individually for the blocks in my Simulink model from the MATLAB command line. I would like this to work with my bus signals as well. command, line, access, port, width, data, type, dimension, simulink, block, simulink.bus MATLAB Answers — New Questions
How can I use “datasample” to get multiple samples without a loop?
How can I create "n" samples of size "k" using "datasample" without needing a "for" loop?
To access detailed documentation on the "datasample" function, execute the following command in MATLAB R2020b:
>> web(fullfile(docroot, ‘stats/datasample.html’))
For example, if I want to sample from a 500 element vector in samples of 20, but do that 30 times, I’ve got to create a loop from i=1:30 with "datasample" inside that loop.How can I create "n" samples of size "k" using "datasample" without needing a "for" loop?
To access detailed documentation on the "datasample" function, execute the following command in MATLAB R2020b:
>> web(fullfile(docroot, ‘stats/datasample.html’))
For example, if I want to sample from a 500 element vector in samples of 20, but do that 30 times, I’ve got to create a loop from i=1:30 with "datasample" inside that loop. How can I create "n" samples of size "k" using "datasample" without needing a "for" loop?
To access detailed documentation on the "datasample" function, execute the following command in MATLAB R2020b:
>> web(fullfile(docroot, ‘stats/datasample.html’))
For example, if I want to sample from a 500 element vector in samples of 20, but do that 30 times, I’ve got to create a loop from i=1:30 with "datasample" inside that loop. MATLAB Answers — New Questions
How do I save a trained deep learning network as plain text?
I have trained a neural network and would like to save it as a text file. How do I save a trained deep learning network as plain text? I am willing to write a script to read and write layers to text but would prefer to use an existing solution if one is available.I have trained a neural network and would like to save it as a text file. How do I save a trained deep learning network as plain text? I am willing to write a script to read and write layers to text but would prefer to use an existing solution if one is available. I have trained a neural network and would like to save it as a text file. How do I save a trained deep learning network as plain text? I am willing to write a script to read and write layers to text but would prefer to use an existing solution if one is available. save, text, deep, learning, neural, network MATLAB Answers — New Questions
How to plot a graph of xy values on android app interface when values are generated from a Simulink model?
For the user interface in Android device, we want to plot a graph of ‘x’ and ‘y’ values where ‘x’ is not time on the android app interface. We can see that there is a block in Simulink called ‘x-y plot’ we can use for our purpose, but this block is currently not supported (as of MATLAB R2020a) for Android. We can have scopes on the screen but can not change the x-axis parameter from time to a customizable parameter. How to plot ‘xy’ values generated from a Simulink model, onto an Android app?For the user interface in Android device, we want to plot a graph of ‘x’ and ‘y’ values where ‘x’ is not time on the android app interface. We can see that there is a block in Simulink called ‘x-y plot’ we can use for our purpose, but this block is currently not supported (as of MATLAB R2020a) for Android. We can have scopes on the screen but can not change the x-axis parameter from time to a customizable parameter. How to plot ‘xy’ values generated from a Simulink model, onto an Android app? For the user interface in Android device, we want to plot a graph of ‘x’ and ‘y’ values where ‘x’ is not time on the android app interface. We can see that there is a block in Simulink called ‘x-y plot’ we can use for our purpose, but this block is currently not supported (as of MATLAB R2020a) for Android. We can have scopes on the screen but can not change the x-axis parameter from time to a customizable parameter. How to plot ‘xy’ values generated from a Simulink model, onto an Android app? plot, xy, array, android MATLAB Answers — New Questions
simulinkが起動しない
Error code:-202
Error message:err_cert_authority_invalidError code:-202
Error message:err_cert_authority_invalid Error code:-202
Error message:err_cert_authority_invalid err_cert_authority_invalid, handles MATLAB Answers — New Questions
Water spray system for dry ice chamber
I previously posted about modeling the sublimation of dry ice, and I am now working on automating the process by introducing water into the tank through a perforated pipe to enhance sublimation. However, I am encountering the following error:
"Nonlinear solver: failed to converge, residual norm too large."
I am unsure how to resolve this issue and would appreciate any guidance on how to correct it.I previously posted about modeling the sublimation of dry ice, and I am now working on automating the process by introducing water into the tank through a perforated pipe to enhance sublimation. However, I am encountering the following error:
"Nonlinear solver: failed to converge, residual norm too large."
I am unsure how to resolve this issue and would appreciate any guidance on how to correct it. I previously posted about modeling the sublimation of dry ice, and I am now working on automating the process by introducing water into the tank through a perforated pipe to enhance sublimation. However, I am encountering the following error:
"Nonlinear solver: failed to converge, residual norm too large."
I am unsure how to resolve this issue and would appreciate any guidance on how to correct it. thermodynamics, fluid dynamics MATLAB Answers — New Questions
Why do I get an Access Denied message when I try to install a MATLAB add on on a mac?
I’m trying to install the Image Processing Toolbox add on. I have a student license.
My macOS is Big Sur, version 11.5.2
The error message just reads
Unable to write to /private/var/folders/cl/wy7k3q2j1_x6ycjphmc_83b80000gn/T/AppTranslocation/751B4B5A-5D40-496E-B6A3-E487ED1228BF/d/MATLAB_R2021b.app
I am the owner of this computer and I’ve tried to install this add on with both my admin and my root accounts. I gave myself permission to read and write to all the folders in that path except the ones after 751B4B5A-5D40-496E-B6A3-E487ED1228BF including that one, as it doesn’t allow me to do it (even though I already disabled System Integrity Protection in order to allow myself to modify the access permissions for the other folders.
What else can I try to install this add on?
Thanks for any helpI’m trying to install the Image Processing Toolbox add on. I have a student license.
My macOS is Big Sur, version 11.5.2
The error message just reads
Unable to write to /private/var/folders/cl/wy7k3q2j1_x6ycjphmc_83b80000gn/T/AppTranslocation/751B4B5A-5D40-496E-B6A3-E487ED1228BF/d/MATLAB_R2021b.app
I am the owner of this computer and I’ve tried to install this add on with both my admin and my root accounts. I gave myself permission to read and write to all the folders in that path except the ones after 751B4B5A-5D40-496E-B6A3-E487ED1228BF including that one, as it doesn’t allow me to do it (even though I already disabled System Integrity Protection in order to allow myself to modify the access permissions for the other folders.
What else can I try to install this add on?
Thanks for any help I’m trying to install the Image Processing Toolbox add on. I have a student license.
My macOS is Big Sur, version 11.5.2
The error message just reads
Unable to write to /private/var/folders/cl/wy7k3q2j1_x6ycjphmc_83b80000gn/T/AppTranslocation/751B4B5A-5D40-496E-B6A3-E487ED1228BF/d/MATLAB_R2021b.app
I am the owner of this computer and I’ve tried to install this add on with both my admin and my root accounts. I gave myself permission to read and write to all the folders in that path except the ones after 751B4B5A-5D40-496E-B6A3-E487ED1228BF including that one, as it doesn’t allow me to do it (even though I already disabled System Integrity Protection in order to allow myself to modify the access permissions for the other folders.
What else can I try to install this add on?
Thanks for any help access denied, add on installation MATLAB Answers — New Questions
HDF Compound Data and “strings”
Hi,
I’m migrating code to Matlab. The data format from the previous language writes out an HDF file, with a compound datatype. This is not the way I would choose to do this in Matlab, I love the higher level functions and almost never touch the lower level ones. However, I’d like to make the new code backwards compatible with previous data which means I also need the compound datatype. It includes strings. I know HDF supports this, but it’s unclear that Matlab supports putting this into an HDF file.
The error message I get is:
Error using hdf5lib2
The class of input data must be integer instead of char when the HDF5 class is H5T_STD_I8LE.
Error in H5D.write (line 100)
H5ML.hdf5lib2(‘H5Dwrite’, varargin{:});
Error in hdfhell2p0 (line 53)
H5D.write(dsetid, cid, ‘H5S_ALL’, ‘H5S_ALL’, ‘H5P_DEFAULT’, params);
I can only assume it’s upset by the char arrays/strings. I’ve tried different versions of creating the strings. I found a piece that said they had to be characters, not strings, so I converted them. I found another that said they had to be uniform in length, so I set a specific length. This one doesn’t make sense to me since I’m only doinn a single value, but hey, grasping at straws.
If i remove the strings/charcters, it works.
So, is there a way to keep the strings and if so, what am I missing?
%%make up a mixed structure
params.floc = ‘C:Folder1’;
params.fname = ‘fname.txt’;
params.value = 10;
%%actual code
outname = ‘test09.h5’;
plist = ‘H5P_DEFAULT’;
fNames = fieldnames(params);
for ii = 1:numel(fNames)
temp = params.(fNames{ii});
if ~isnan(str2double(temp))
params.(fNames{ii}) = str2double(temp);
Vsize(ii) = 8;
Vclass{ii} = ‘H5T_NATIVE_DOUBLE’;
elseif ischar(temp)
temp = char(pad(params.(fNames{ii}),15,’right’));
params.(fNames{ii}) = temp;
Vsize(ii) = strlength(temp);
Vclass{ii}= ‘H5T_NATIVE_CHAR’;
end
end
H5F.create(outname, ‘H5F_ACC_TRUNC’, ‘H5P_DEFAULT’, ‘H5P_DEFAULT’);
fid = H5F.open(outname,’H5F_ACC_RDWR’,plist);
H5G.create(fid,’/SETTINGS’,plist,plist,plist);
gid = H5G.open(fid,’/SETTINGS’);
cid = H5T.create(‘H5T_COMPOUND’, sum(Vsize));
for ii = 1:numel(fNames)
if ii == 1
H5T.insert(cid, fNames{ii}, 0, H5T.copy(Vclass{ii}));
else
if strcmp(Vclass{ii},’H5T_NATIVE_CHAR’)
string_type = H5T.array_create(H5T.copy(‘H5T_NATIVE_CHAR’), 1, 20);
H5T.insert(cid, fNames{ii}, sum(Vsize(1:(ii-1))), string_type)
else
H5T.insert(cid, fNames{ii}, sum(Vsize(1:(ii-1))), H5T.copy(Vclass{ii}));
end
end
end
dsid = H5S.create_simple(1,1,[]);
dsetid = H5D.create(fid, ‘/SETTINGS/PASS’, cid, dsid, ‘H5P_DEFAULT’);
H5D.write(dsetid, cid, ‘H5S_ALL’, ‘H5S_ALL’, ‘H5P_DEFAULT’, params);
H5D.close(dsetid)
H5S.close(did)
H5T.close(cid)
H5G.close(gid)
H5F.close(fid)Hi,
I’m migrating code to Matlab. The data format from the previous language writes out an HDF file, with a compound datatype. This is not the way I would choose to do this in Matlab, I love the higher level functions and almost never touch the lower level ones. However, I’d like to make the new code backwards compatible with previous data which means I also need the compound datatype. It includes strings. I know HDF supports this, but it’s unclear that Matlab supports putting this into an HDF file.
The error message I get is:
Error using hdf5lib2
The class of input data must be integer instead of char when the HDF5 class is H5T_STD_I8LE.
Error in H5D.write (line 100)
H5ML.hdf5lib2(‘H5Dwrite’, varargin{:});
Error in hdfhell2p0 (line 53)
H5D.write(dsetid, cid, ‘H5S_ALL’, ‘H5S_ALL’, ‘H5P_DEFAULT’, params);
I can only assume it’s upset by the char arrays/strings. I’ve tried different versions of creating the strings. I found a piece that said they had to be characters, not strings, so I converted them. I found another that said they had to be uniform in length, so I set a specific length. This one doesn’t make sense to me since I’m only doinn a single value, but hey, grasping at straws.
If i remove the strings/charcters, it works.
So, is there a way to keep the strings and if so, what am I missing?
%%make up a mixed structure
params.floc = ‘C:Folder1’;
params.fname = ‘fname.txt’;
params.value = 10;
%%actual code
outname = ‘test09.h5’;
plist = ‘H5P_DEFAULT’;
fNames = fieldnames(params);
for ii = 1:numel(fNames)
temp = params.(fNames{ii});
if ~isnan(str2double(temp))
params.(fNames{ii}) = str2double(temp);
Vsize(ii) = 8;
Vclass{ii} = ‘H5T_NATIVE_DOUBLE’;
elseif ischar(temp)
temp = char(pad(params.(fNames{ii}),15,’right’));
params.(fNames{ii}) = temp;
Vsize(ii) = strlength(temp);
Vclass{ii}= ‘H5T_NATIVE_CHAR’;
end
end
H5F.create(outname, ‘H5F_ACC_TRUNC’, ‘H5P_DEFAULT’, ‘H5P_DEFAULT’);
fid = H5F.open(outname,’H5F_ACC_RDWR’,plist);
H5G.create(fid,’/SETTINGS’,plist,plist,plist);
gid = H5G.open(fid,’/SETTINGS’);
cid = H5T.create(‘H5T_COMPOUND’, sum(Vsize));
for ii = 1:numel(fNames)
if ii == 1
H5T.insert(cid, fNames{ii}, 0, H5T.copy(Vclass{ii}));
else
if strcmp(Vclass{ii},’H5T_NATIVE_CHAR’)
string_type = H5T.array_create(H5T.copy(‘H5T_NATIVE_CHAR’), 1, 20);
H5T.insert(cid, fNames{ii}, sum(Vsize(1:(ii-1))), string_type)
else
H5T.insert(cid, fNames{ii}, sum(Vsize(1:(ii-1))), H5T.copy(Vclass{ii}));
end
end
end
dsid = H5S.create_simple(1,1,[]);
dsetid = H5D.create(fid, ‘/SETTINGS/PASS’, cid, dsid, ‘H5P_DEFAULT’);
H5D.write(dsetid, cid, ‘H5S_ALL’, ‘H5S_ALL’, ‘H5P_DEFAULT’, params);
H5D.close(dsetid)
H5S.close(did)
H5T.close(cid)
H5G.close(gid)
H5F.close(fid) Hi,
I’m migrating code to Matlab. The data format from the previous language writes out an HDF file, with a compound datatype. This is not the way I would choose to do this in Matlab, I love the higher level functions and almost never touch the lower level ones. However, I’d like to make the new code backwards compatible with previous data which means I also need the compound datatype. It includes strings. I know HDF supports this, but it’s unclear that Matlab supports putting this into an HDF file.
The error message I get is:
Error using hdf5lib2
The class of input data must be integer instead of char when the HDF5 class is H5T_STD_I8LE.
Error in H5D.write (line 100)
H5ML.hdf5lib2(‘H5Dwrite’, varargin{:});
Error in hdfhell2p0 (line 53)
H5D.write(dsetid, cid, ‘H5S_ALL’, ‘H5S_ALL’, ‘H5P_DEFAULT’, params);
I can only assume it’s upset by the char arrays/strings. I’ve tried different versions of creating the strings. I found a piece that said they had to be characters, not strings, so I converted them. I found another that said they had to be uniform in length, so I set a specific length. This one doesn’t make sense to me since I’m only doinn a single value, but hey, grasping at straws.
If i remove the strings/charcters, it works.
So, is there a way to keep the strings and if so, what am I missing?
%%make up a mixed structure
params.floc = ‘C:Folder1’;
params.fname = ‘fname.txt’;
params.value = 10;
%%actual code
outname = ‘test09.h5’;
plist = ‘H5P_DEFAULT’;
fNames = fieldnames(params);
for ii = 1:numel(fNames)
temp = params.(fNames{ii});
if ~isnan(str2double(temp))
params.(fNames{ii}) = str2double(temp);
Vsize(ii) = 8;
Vclass{ii} = ‘H5T_NATIVE_DOUBLE’;
elseif ischar(temp)
temp = char(pad(params.(fNames{ii}),15,’right’));
params.(fNames{ii}) = temp;
Vsize(ii) = strlength(temp);
Vclass{ii}= ‘H5T_NATIVE_CHAR’;
end
end
H5F.create(outname, ‘H5F_ACC_TRUNC’, ‘H5P_DEFAULT’, ‘H5P_DEFAULT’);
fid = H5F.open(outname,’H5F_ACC_RDWR’,plist);
H5G.create(fid,’/SETTINGS’,plist,plist,plist);
gid = H5G.open(fid,’/SETTINGS’);
cid = H5T.create(‘H5T_COMPOUND’, sum(Vsize));
for ii = 1:numel(fNames)
if ii == 1
H5T.insert(cid, fNames{ii}, 0, H5T.copy(Vclass{ii}));
else
if strcmp(Vclass{ii},’H5T_NATIVE_CHAR’)
string_type = H5T.array_create(H5T.copy(‘H5T_NATIVE_CHAR’), 1, 20);
H5T.insert(cid, fNames{ii}, sum(Vsize(1:(ii-1))), string_type)
else
H5T.insert(cid, fNames{ii}, sum(Vsize(1:(ii-1))), H5T.copy(Vclass{ii}));
end
end
end
dsid = H5S.create_simple(1,1,[]);
dsetid = H5D.create(fid, ‘/SETTINGS/PASS’, cid, dsid, ‘H5P_DEFAULT’);
H5D.write(dsetid, cid, ‘H5S_ALL’, ‘H5S_ALL’, ‘H5P_DEFAULT’, params);
H5D.close(dsetid)
H5S.close(did)
H5T.close(cid)
H5G.close(gid)
H5F.close(fid) h5, hdf, compound data type, strings and hdf MATLAB Answers — New Questions
Is there a way to save the filename used in a live script Import Data task?
I am new to live scripts and although the streamlined functionality seems like a real time-saver it also obfuscates how some of the functions are working. The data processing activity that I am currently working on is quite straightfoward; choose CSV file from whatever is available in the working folder, import the data and structure it to be processed, prompt user to set the range of interest using sliders (which is an awesome feature that saves having to sanitize my data before import), then process and plot the result. Everything works great, but I can’t figure out how to use the filename of what is being imported as a variable…
In the past, before I was exposed to live scripts and the built-in tasks, I just wrote my code to have a commented line for the user to enter the filename which meant I could chop that filename up into useful pieces assuming it was named accordingly (for example: serialnumber_testnumber_operator.csv). Having that nicely structured filename allowed me to batch process any arbitrary number of data sets from a folder and spit out plots that were named for each data file (think "Y vs X, SN011 Test 3") which was great.
Setting my code up as a live script and changing the view to "hide code" makes a beatifully simple screen that I can turn over to people who don’t know anything about MATLAB for them to process data without my involvement, but I need that filename variable so that I can get the plots saved properly with their descriptive names. I’ve been sort of beating my head against the wall here trying to figure out how to do that, so I figured I should try asking for help.
Here’s the trail of breadcrumbs that I have followed so far starting within the code that exists in the Import Data task:
From this block:
% Import the data
rawdata = readtable("filepathfilename.csv")
If I step into the readtable function it goes straight into the ImportOptions function to line 496:
function T = readtable(filename,opts,varargin)
if ~isa(opts,’matlab.io.ImportOptions’)
error(message(‘MATLAB:textio:io:OptsSecondArg’,’readtable’))
end
try
func = matlab.io.internal.functions.FunctionStore.getFunctionByName(‘readtableWithImportOptions’);
T = func.validateAndExecute(filename,opts,varargin{:});
catch ME
throw(ME);
end
end
During that time the filename exists as a variable, but as soon as it steps out of the ImportOptions block filename disappears. If anyone can help me understand how to save that variable, it would be greatly appreciated.I am new to live scripts and although the streamlined functionality seems like a real time-saver it also obfuscates how some of the functions are working. The data processing activity that I am currently working on is quite straightfoward; choose CSV file from whatever is available in the working folder, import the data and structure it to be processed, prompt user to set the range of interest using sliders (which is an awesome feature that saves having to sanitize my data before import), then process and plot the result. Everything works great, but I can’t figure out how to use the filename of what is being imported as a variable…
In the past, before I was exposed to live scripts and the built-in tasks, I just wrote my code to have a commented line for the user to enter the filename which meant I could chop that filename up into useful pieces assuming it was named accordingly (for example: serialnumber_testnumber_operator.csv). Having that nicely structured filename allowed me to batch process any arbitrary number of data sets from a folder and spit out plots that were named for each data file (think "Y vs X, SN011 Test 3") which was great.
Setting my code up as a live script and changing the view to "hide code" makes a beatifully simple screen that I can turn over to people who don’t know anything about MATLAB for them to process data without my involvement, but I need that filename variable so that I can get the plots saved properly with their descriptive names. I’ve been sort of beating my head against the wall here trying to figure out how to do that, so I figured I should try asking for help.
Here’s the trail of breadcrumbs that I have followed so far starting within the code that exists in the Import Data task:
From this block:
% Import the data
rawdata = readtable("filepathfilename.csv")
If I step into the readtable function it goes straight into the ImportOptions function to line 496:
function T = readtable(filename,opts,varargin)
if ~isa(opts,’matlab.io.ImportOptions’)
error(message(‘MATLAB:textio:io:OptsSecondArg’,’readtable’))
end
try
func = matlab.io.internal.functions.FunctionStore.getFunctionByName(‘readtableWithImportOptions’);
T = func.validateAndExecute(filename,opts,varargin{:});
catch ME
throw(ME);
end
end
During that time the filename exists as a variable, but as soon as it steps out of the ImportOptions block filename disappears. If anyone can help me understand how to save that variable, it would be greatly appreciated. I am new to live scripts and although the streamlined functionality seems like a real time-saver it also obfuscates how some of the functions are working. The data processing activity that I am currently working on is quite straightfoward; choose CSV file from whatever is available in the working folder, import the data and structure it to be processed, prompt user to set the range of interest using sliders (which is an awesome feature that saves having to sanitize my data before import), then process and plot the result. Everything works great, but I can’t figure out how to use the filename of what is being imported as a variable…
In the past, before I was exposed to live scripts and the built-in tasks, I just wrote my code to have a commented line for the user to enter the filename which meant I could chop that filename up into useful pieces assuming it was named accordingly (for example: serialnumber_testnumber_operator.csv). Having that nicely structured filename allowed me to batch process any arbitrary number of data sets from a folder and spit out plots that were named for each data file (think "Y vs X, SN011 Test 3") which was great.
Setting my code up as a live script and changing the view to "hide code" makes a beatifully simple screen that I can turn over to people who don’t know anything about MATLAB for them to process data without my involvement, but I need that filename variable so that I can get the plots saved properly with their descriptive names. I’ve been sort of beating my head against the wall here trying to figure out how to do that, so I figured I should try asking for help.
Here’s the trail of breadcrumbs that I have followed so far starting within the code that exists in the Import Data task:
From this block:
% Import the data
rawdata = readtable("filepathfilename.csv")
If I step into the readtable function it goes straight into the ImportOptions function to line 496:
function T = readtable(filename,opts,varargin)
if ~isa(opts,’matlab.io.ImportOptions’)
error(message(‘MATLAB:textio:io:OptsSecondArg’,’readtable’))
end
try
func = matlab.io.internal.functions.FunctionStore.getFunctionByName(‘readtableWithImportOptions’);
T = func.validateAndExecute(filename,opts,varargin{:});
catch ME
throw(ME);
end
end
During that time the filename exists as a variable, but as soon as it steps out of the ImportOptions block filename disappears. If anyone can help me understand how to save that variable, it would be greatly appreciated. live script, data import, filename MATLAB Answers — New Questions
Step response is not showing up in the legend of my plot
I am trying to plot both the experimental and simulated (step function of a first order transfer function) data. Both of the data sets are being displayed on the same graph, but when I try to put a legend on the plot it only says the step function is "untitled 1"I am trying to plot both the experimental and simulated (step function of a first order transfer function) data. Both of the data sets are being displayed on the same graph, but when I try to put a legend on the plot it only says the step function is "untitled 1" I am trying to plot both the experimental and simulated (step function of a first order transfer function) data. Both of the data sets are being displayed on the same graph, but when I try to put a legend on the plot it only says the step function is "untitled 1" plot, step MATLAB Answers — New Questions
How to use all CPU cores
I have 16 cores and 32 logical processors but only 16 out of the 32 processors are being used for my Matlab which takes very long run time. How can I make my computer to utilize all of the CPU and processors?I have 16 cores and 32 logical processors but only 16 out of the 32 processors are being used for my Matlab which takes very long run time. How can I make my computer to utilize all of the CPU and processors? I have 16 cores and 32 logical processors but only 16 out of the 32 processors are being used for my Matlab which takes very long run time. How can I make my computer to utilize all of the CPU and processors? cpu, processors, runtime, neural network MATLAB Answers — New Questions
How to make color axis ticklabes with two end limits ([cmin cmax]) only?
Suppose, I have subplots of 4 times 3 or higher and I cant change clim of each plot using property inspector. I tried
clim([cmin cmax])
but that shows a full range instead of two ticklabels (with auto ticks) only. is there a way to fix two end limits with ticklabes on the color axis. Thanks.
Edited:syntax for ticklabes (not ticks) as cmin and cmax .Suppose, I have subplots of 4 times 3 or higher and I cant change clim of each plot using property inspector. I tried
clim([cmin cmax])
but that shows a full range instead of two ticklabels (with auto ticks) only. is there a way to fix two end limits with ticklabes on the color axis. Thanks.
Edited:syntax for ticklabes (not ticks) as cmin and cmax . Suppose, I have subplots of 4 times 3 or higher and I cant change clim of each plot using property inspector. I tried
clim([cmin cmax])
but that shows a full range instead of two ticklabels (with auto ticks) only. is there a way to fix two end limits with ticklabes on the color axis. Thanks.
Edited:syntax for ticklabes (not ticks) as cmin and cmax . colormap, axis, subplot, plot, plotting MATLAB Answers — New Questions
MATLAB error OS-ELM model
Hello
Code will running gives a basic error while calling the function. ‘Not enough input arguments’
I have tried my best but it is not working out. Can anyone please check the code. I am attaching the data file and the inbuilt function.
Thanks very much in advance
EvaHello
Code will running gives a basic error while calling the function. ‘Not enough input arguments’
I have tried my best but it is not working out. Can anyone please check the code. I am attaching the data file and the inbuilt function.
Thanks very much in advance
Eva Hello
Code will running gives a basic error while calling the function. ‘Not enough input arguments’
I have tried my best but it is not working out. Can anyone please check the code. I am attaching the data file and the inbuilt function.
Thanks very much in advance
Eva os-elm, elm MATLAB Answers — New Questions
Transfer matrix Method for trilayer
%TMM 3 Layers
% SOURCE PARAMETERS
c = 3e8; % Speed of light in vacuum
% Operating frequencies
lmd = 800e-9;
freq = c./lmd;
omega = 2.*pi.*freq;
% Wavevector for free space
K0 = (2*pi)./lmd;
N = 1; % Number of layers excluding substrate and superstate
% Permivittity values
eps = [1,2.25,1];
% perambility values
mu = [1,1,1]; %permeability of every layer
% Refractive index
n = [sqrt((eps(1)*mu(1))),sqrt((eps(2)*mu(2))),sqrt((eps(3)*mu(3)))];
% Layer thickness
d = [600e-9,200e-9,600e-9]; %thickness of 2nd, 3rd and 4th layer in nm
% Angle of incidences
theta = 0:5:90;
thetaa = [0 0 0]; % Incident angles(in degrees)
% Wave vector
k2x = n(1,2).*(omega./c).*cosd(thetaa(1,2));
% Propagation Matrix
phi2 = k2x*d(1,2);
P2 = [exp(1i*phi2) 0; 0 exp(-1i*phi2)];
D1=zeros(2,length(theta));
% Dynamical matrix 1
D1_11 = 1;
D1_12 = 1;
D1_21 = n(1,1).*cosd(theta);
D1_22 = -n(1,1).*cosd(theta);
% D1 = [D1_11 D1_12; D1_21 D1_22]
% Dynamical matrix 2
D2_11 = 1;
D2_12 = 1;
D2_21 = n(1,2)*cosd(theta(1,2));
D2_22 = -n(1,2)*cosd(theta(1,2));
% D2 = [D2_11 D2_12; D2_21 D2_22]
% Dynamical matrix
D3_11 = 1;
D3_12 = 1;
D3_21 = n(1,3)*cosd(theta(1,3));
D3_22 = -n(1,3)*cosd(theta(1,3));
% D3 = [D3_11 D3_12; D3_21 D3_22]
for ii = 1:length(theta)
D_1 = [D1_11(1,ii) D1_12(1,ii); D1_21(1,ii) D1_22(1,ii)]
D_2 = [D2_11(1,ii) D2_12(1,ii); D2_21(1,ii) D2_22(1,ii)]
D_3 = [D3_11(1,ii) D3_12(1,ii); D3_21(1,ii) D3_22(1,ii)]
M = D_1^(-1)*D_2*P2*D_2^(-1)*D_3;
rs = M(2,1)./M(1,1)
ts = 1./M(1,1)
Rs = abs(rs.^2)
Ts = ((n(1,3).*cosd(thetaa(1,3))./(n(1,1).*cosd(theta))).*abs(ts.^2))
Frensel_s = Rs + Ts
end
% Dynamical Matrix for S – Wave
plot(theta,Rs,theta,Ts)
legend(‘R’,’T’)
%% Graph output should be like this%TMM 3 Layers
% SOURCE PARAMETERS
c = 3e8; % Speed of light in vacuum
% Operating frequencies
lmd = 800e-9;
freq = c./lmd;
omega = 2.*pi.*freq;
% Wavevector for free space
K0 = (2*pi)./lmd;
N = 1; % Number of layers excluding substrate and superstate
% Permivittity values
eps = [1,2.25,1];
% perambility values
mu = [1,1,1]; %permeability of every layer
% Refractive index
n = [sqrt((eps(1)*mu(1))),sqrt((eps(2)*mu(2))),sqrt((eps(3)*mu(3)))];
% Layer thickness
d = [600e-9,200e-9,600e-9]; %thickness of 2nd, 3rd and 4th layer in nm
% Angle of incidences
theta = 0:5:90;
thetaa = [0 0 0]; % Incident angles(in degrees)
% Wave vector
k2x = n(1,2).*(omega./c).*cosd(thetaa(1,2));
% Propagation Matrix
phi2 = k2x*d(1,2);
P2 = [exp(1i*phi2) 0; 0 exp(-1i*phi2)];
D1=zeros(2,length(theta));
% Dynamical matrix 1
D1_11 = 1;
D1_12 = 1;
D1_21 = n(1,1).*cosd(theta);
D1_22 = -n(1,1).*cosd(theta);
% D1 = [D1_11 D1_12; D1_21 D1_22]
% Dynamical matrix 2
D2_11 = 1;
D2_12 = 1;
D2_21 = n(1,2)*cosd(theta(1,2));
D2_22 = -n(1,2)*cosd(theta(1,2));
% D2 = [D2_11 D2_12; D2_21 D2_22]
% Dynamical matrix
D3_11 = 1;
D3_12 = 1;
D3_21 = n(1,3)*cosd(theta(1,3));
D3_22 = -n(1,3)*cosd(theta(1,3));
% D3 = [D3_11 D3_12; D3_21 D3_22]
for ii = 1:length(theta)
D_1 = [D1_11(1,ii) D1_12(1,ii); D1_21(1,ii) D1_22(1,ii)]
D_2 = [D2_11(1,ii) D2_12(1,ii); D2_21(1,ii) D2_22(1,ii)]
D_3 = [D3_11(1,ii) D3_12(1,ii); D3_21(1,ii) D3_22(1,ii)]
M = D_1^(-1)*D_2*P2*D_2^(-1)*D_3;
rs = M(2,1)./M(1,1)
ts = 1./M(1,1)
Rs = abs(rs.^2)
Ts = ((n(1,3).*cosd(thetaa(1,3))./(n(1,1).*cosd(theta))).*abs(ts.^2))
Frensel_s = Rs + Ts
end
% Dynamical Matrix for S – Wave
plot(theta,Rs,theta,Ts)
legend(‘R’,’T’)
%% Graph output should be like this %TMM 3 Layers
% SOURCE PARAMETERS
c = 3e8; % Speed of light in vacuum
% Operating frequencies
lmd = 800e-9;
freq = c./lmd;
omega = 2.*pi.*freq;
% Wavevector for free space
K0 = (2*pi)./lmd;
N = 1; % Number of layers excluding substrate and superstate
% Permivittity values
eps = [1,2.25,1];
% perambility values
mu = [1,1,1]; %permeability of every layer
% Refractive index
n = [sqrt((eps(1)*mu(1))),sqrt((eps(2)*mu(2))),sqrt((eps(3)*mu(3)))];
% Layer thickness
d = [600e-9,200e-9,600e-9]; %thickness of 2nd, 3rd and 4th layer in nm
% Angle of incidences
theta = 0:5:90;
thetaa = [0 0 0]; % Incident angles(in degrees)
% Wave vector
k2x = n(1,2).*(omega./c).*cosd(thetaa(1,2));
% Propagation Matrix
phi2 = k2x*d(1,2);
P2 = [exp(1i*phi2) 0; 0 exp(-1i*phi2)];
D1=zeros(2,length(theta));
% Dynamical matrix 1
D1_11 = 1;
D1_12 = 1;
D1_21 = n(1,1).*cosd(theta);
D1_22 = -n(1,1).*cosd(theta);
% D1 = [D1_11 D1_12; D1_21 D1_22]
% Dynamical matrix 2
D2_11 = 1;
D2_12 = 1;
D2_21 = n(1,2)*cosd(theta(1,2));
D2_22 = -n(1,2)*cosd(theta(1,2));
% D2 = [D2_11 D2_12; D2_21 D2_22]
% Dynamical matrix
D3_11 = 1;
D3_12 = 1;
D3_21 = n(1,3)*cosd(theta(1,3));
D3_22 = -n(1,3)*cosd(theta(1,3));
% D3 = [D3_11 D3_12; D3_21 D3_22]
for ii = 1:length(theta)
D_1 = [D1_11(1,ii) D1_12(1,ii); D1_21(1,ii) D1_22(1,ii)]
D_2 = [D2_11(1,ii) D2_12(1,ii); D2_21(1,ii) D2_22(1,ii)]
D_3 = [D3_11(1,ii) D3_12(1,ii); D3_21(1,ii) D3_22(1,ii)]
M = D_1^(-1)*D_2*P2*D_2^(-1)*D_3;
rs = M(2,1)./M(1,1)
ts = 1./M(1,1)
Rs = abs(rs.^2)
Ts = ((n(1,3).*cosd(thetaa(1,3))./(n(1,1).*cosd(theta))).*abs(ts.^2))
Frensel_s = Rs + Ts
end
% Dynamical Matrix for S – Wave
plot(theta,Rs,theta,Ts)
legend(‘R’,’T’)
%% Graph output should be like this transfer matrix method MATLAB Answers — New Questions
MCRInstaller.bin issue
Hello Everyone,
I want to extract and run the MCRInstaller.bin in MATLAB_2010b through these commands in Linux amd64:
RUN chmod 0777 /opt/matlab_2010b/MCRInstaller.bin
RUN ./matlab_2010b/MCRInstaller.bin -silent
first issue is that it doesn’t extract and secondly it doesn’t recognize my JAVA (JRE).
I would appreciate any comments or advice.
Thanks,
SanamHello Everyone,
I want to extract and run the MCRInstaller.bin in MATLAB_2010b through these commands in Linux amd64:
RUN chmod 0777 /opt/matlab_2010b/MCRInstaller.bin
RUN ./matlab_2010b/MCRInstaller.bin -silent
first issue is that it doesn’t extract and secondly it doesn’t recognize my JAVA (JRE).
I would appreciate any comments or advice.
Thanks,
Sanam Hello Everyone,
I want to extract and run the MCRInstaller.bin in MATLAB_2010b through these commands in Linux amd64:
RUN chmod 0777 /opt/matlab_2010b/MCRInstaller.bin
RUN ./matlab_2010b/MCRInstaller.bin -silent
first issue is that it doesn’t extract and secondly it doesn’t recognize my JAVA (JRE).
I would appreciate any comments or advice.
Thanks,
Sanam mcrinstaller.bin, matlab_2010b, mcrinstaller version 714 MATLAB Answers — New Questions
how to update MATLAB 2024b when cannot uninstall old version
I tried to install latest 2024b version but got the already installed message. So I then went to the control panel to uninstall the prior release of 2024b but it was not listed so noting to click on to uninstall. Now what? I guees wait for 2025a.I tried to install latest 2024b version but got the already installed message. So I then went to the control panel to uninstall the prior release of 2024b but it was not listed so noting to click on to uninstall. Now what? I guees wait for 2025a. I tried to install latest 2024b version but got the already installed message. So I then went to the control panel to uninstall the prior release of 2024b but it was not listed so noting to click on to uninstall. Now what? I guees wait for 2025a. matlab, 2024b, uninstall MATLAB Answers — New Questions
How can I run a Montecarlo simulation in Simulink?
Hello
I have a system being run in Simulink I get outputs , but it is being deterministic , how can I achieve a stochastic simulation? cause I have a lot of parameters therefor having the full set of parameters makes it impossible take it all possibilities accountable. How can I create this type of graphic? Next is a plot from Goldsim simulator results that asummes stochastic values for entrance, as instance.thanks in advanceHello
I have a system being run in Simulink I get outputs , but it is being deterministic , how can I achieve a stochastic simulation? cause I have a lot of parameters therefor having the full set of parameters makes it impossible take it all possibilities accountable. How can I create this type of graphic? Next is a plot from Goldsim simulator results that asummes stochastic values for entrance, as instance.thanks in advance Hello
I have a system being run in Simulink I get outputs , but it is being deterministic , how can I achieve a stochastic simulation? cause I have a lot of parameters therefor having the full set of parameters makes it impossible take it all possibilities accountable. How can I create this type of graphic? Next is a plot from Goldsim simulator results that asummes stochastic values for entrance, as instance.thanks in advance simulink, matlab, monte carlo, stochastic, deterministic MATLAB Answers — New Questions
Why does the “goertzel” function not accept arguments in [N, N + 1) as the FFT index for signal inputs of length N in MATLAB R2024a and earlier?
Why does the "goertzel" function not accept arguments in [N, N + 1) as the FFT index for signal inputs of length N in MATLAB R2024a and earlier?
Specifically, I get a "Maximum Index exceeds the dimensions of X." error when running the following code:
>> Fs = 8000;
>> N = 205;
>> lo = sin(2*pi*697*(0:N-1)/Fs);
>> hi = sin(2*pi*1209*(0:N-1)/Fs);
>> data = lo + hi;
>> goertzel(data,205.5)
Error using goertzel (line 143)
Maximum Index exceeds the dimensions of X.
Error in goertzel (line 100)
Y1 = goertzel(reshape(X,coder.internal.indexInt(size(X,2)),ONE),INDVEC,1);Why does the "goertzel" function not accept arguments in [N, N + 1) as the FFT index for signal inputs of length N in MATLAB R2024a and earlier?
Specifically, I get a "Maximum Index exceeds the dimensions of X." error when running the following code:
>> Fs = 8000;
>> N = 205;
>> lo = sin(2*pi*697*(0:N-1)/Fs);
>> hi = sin(2*pi*1209*(0:N-1)/Fs);
>> data = lo + hi;
>> goertzel(data,205.5)
Error using goertzel (line 143)
Maximum Index exceeds the dimensions of X.
Error in goertzel (line 100)
Y1 = goertzel(reshape(X,coder.internal.indexInt(size(X,2)),ONE),INDVEC,1); Why does the "goertzel" function not accept arguments in [N, N + 1) as the FFT index for signal inputs of length N in MATLAB R2024a and earlier?
Specifically, I get a "Maximum Index exceeds the dimensions of X." error when running the following code:
>> Fs = 8000;
>> N = 205;
>> lo = sin(2*pi*697*(0:N-1)/Fs);
>> hi = sin(2*pi*1209*(0:N-1)/Fs);
>> data = lo + hi;
>> goertzel(data,205.5)
Error using goertzel (line 143)
Maximum Index exceeds the dimensions of X.
Error in goertzel (line 100)
Y1 = goertzel(reshape(X,coder.internal.indexInt(size(X,2)),ONE),INDVEC,1); goertzel, signalprocessing MATLAB Answers — New Questions
How do I make shaded error bar area instead of lines?
I have data as a neuronal response function listed as my first line of code which is the curve I get. I am trying to add shaded error bars that look similar to this:
My code is:
load(‘0_RF_PSD95-3_20111121-3.CNG.swc_Trials_120_length_2000_p_0.995_a_0.8_beta_0.6.mat’)
SDdiff = std(diff(sort(Fsoma)));
figure; errorbar(h(2:end), diff(mean(Fsoma/500)), …
SDdiff(2:end)/500);
set(gca, ‘XScale’, ‘log’)
and my current figure/output is:
Does anyone know how to help me achieve something similar to the first figure? Thank you in advance.I have data as a neuronal response function listed as my first line of code which is the curve I get. I am trying to add shaded error bars that look similar to this:
My code is:
load(‘0_RF_PSD95-3_20111121-3.CNG.swc_Trials_120_length_2000_p_0.995_a_0.8_beta_0.6.mat’)
SDdiff = std(diff(sort(Fsoma)));
figure; errorbar(h(2:end), diff(mean(Fsoma/500)), …
SDdiff(2:end)/500);
set(gca, ‘XScale’, ‘log’)
and my current figure/output is:
Does anyone know how to help me achieve something similar to the first figure? Thank you in advance. I have data as a neuronal response function listed as my first line of code which is the curve I get. I am trying to add shaded error bars that look similar to this:
My code is:
load(‘0_RF_PSD95-3_20111121-3.CNG.swc_Trials_120_length_2000_p_0.995_a_0.8_beta_0.6.mat’)
SDdiff = std(diff(sort(Fsoma)));
figure; errorbar(h(2:end), diff(mean(Fsoma/500)), …
SDdiff(2:end)/500);
set(gca, ‘XScale’, ‘log’)
and my current figure/output is:
Does anyone know how to help me achieve something similar to the first figure? Thank you in advance. shadederrorbar, errorbar MATLAB Answers — New Questions