Science topic

Programming in MATLAB - Science topic

Explore the latest questions and answers in Programming in MATLAB, and find Programming in MATLAB experts.
Questions related to Programming in MATLAB
  • asked a question related to Programming in MATLAB
Question
2 answers
Dear researchers,
Can anyone share the Visual Basic or Matlab Code of the membrane distillation process with me?
Thank you so much.
Regards
Relevant answer
Answer
Dear Foroogh Khodadadi:
You can benefit from these valuable Links about your topic:
I hope it will be helpful ...
Best wishes ...
  • asked a question related to Programming in MATLAB
Question
6 answers
The Unscented Kalman Filter (UKF) algorithm requires a Cholesky factorization of the prediction error covariance matrix. The problem is that during the iterations, this matrix is not always positive definite and so, the MATLAB code risks tobe stopped.
Could someone tell me how to make this covariance matrix positive definite in order to ensure the running of the code until the end of the iterations?
Thank you
Relevant answer
Answer
You could also try a factorized implementation. See
The UKF is a nice option for many systems. If you want to keep it simple, often Partial-Update Kalman filter is highly practical but still effective.
  • asked a question related to Programming in MATLAB
Question
3 answers
Using Python, I would like to convert PSD (G2/Hz vs Frequency) diagrams to Acceleration vs Time diagrams. Would someone be able to provide some insight into this matter, because I would like to know first whether or not this can be accomplished and if so, how?
Relevant answer
Answer
DearRavi Patel:
At the first, and as you know we can say the following information:
Vibration Research software uses Welch’s method for power spectral density (PSD) estimation. This method applies the fast Fourier transform (FFT) algorithm to the estimation of power spectra.
In regards to his method, Peter D. Welch said, “[the] principal advantages of this method are a reduction in the number of computations and in required core storage, and convenient application in non-stationarity tests.”
The process begins with Gaussian-distributed time-domain input data—i.e., a time history file.
Relying on the above، you can benefit from this valuable article about your topic:
"Calculating PSD from a Time History File"
I hope it will be helpful ...
Best regards ...
  • asked a question related to Programming in MATLAB
Question
13 answers
I can make a linear mechanical finite element code, but I can't make nonlinear because I don't understand that how the master matrix is varying.
Relevant answer
Answer
If anybody have the code for standard problem of (Non-Linear Transient 2D problem) mentioned in JN Reddy Non-Linear FEA book, please share the code. Any help will be helpful.
  • asked a question related to Programming in MATLAB
Question
5 answers
In his name is the judge
Hi
I want design cotroller in to control active force of damper.
On this purpose, i analyzed structure with damper, wich is tlcdg, and get data whic use for generate controller. data are accleration and velocity of damper as input and dampers force as output ( i mean force wich made by own damper under earthquake excitation, not active force).
here is anfis properties :
number of inputs are 2
number of outputs is 1
generate fis method is grid partition
number of membership function are 4 for each input
input membership function type is guass2mf
output membership function type is linear
opt method is "hybrid".
(have to say i tried different epochs membership function , .....)
Unfortunately anfis toolbox in matlab refuse to train and build Suitable fuzzy controller wich means error is too much in training, so this answer is not acceptable.
i have some idea for make it true but i'm not sure.
here is my ideas :
* first i think train controller with more or less data ( training data are about 2000 wich is under 100s earthquake excitation but when i reduce earthquake excitation to 10 or 15 seconds the error is acceptable however i think this solution is not good.)
* second maybe i must try one damper for training.
* the last idea is to assign force on the damper location and get acceleration and velacity for generate trianing data.
here is my data and shot frome my try.
Any help is greatly appreciated.
Take refuge in the right.
Relevant answer
Answer
Gracias por su sugerencia
Definitivamente revisaré
  • asked a question related to Programming in MATLAB
Question
6 answers
I need help to implement matlab code the equations 5,8 and 9 in the attached file. In order to estimate Alpha i designed range [0:.1:180] steps and estimate Alpha but dont know picking up the idea how to find Beta using 8-9. Please need your expert advice.
If anyone have some basic code for 2-D MUSIC share with me please.
  • asked a question related to Programming in MATLAB
Question
2 answers
Hi,
I really need some help. I acknowledge all respected researchers here which have done raindrop size distribution studies using t-matrix code written and provided by Mishchenko.
It says the codes were all written using fortran77.
But, to be frank. I have never used Fortran and I am not a programmer. So, for my study, I'm using Matlab. To convert fortran77 to Matlab, I need to convert fortran77 to fortran90 first which I totally have no clue.
So, I would like to ask if any of my Researchgate friends here are willing to share the converted version (in Matlab code) or have any info about this code. All help are highly appreciated.
Relevant answer
Answer
I went to the NASA web site and downloaded the first file I came to (tmp.lp.f). While it is indeed F77, converting it to something you might use in a different development environment (MATLAB or Python or C) will be quite a challenge. There are several features used in this code which are peculiar to arcane FORTRAN compilers, operating systems, and processors (REAL*16 and COMPLEX*32 objects and quadruple precision constants, which were available on the IBM 360 mainframe and Alpha workstations that cost more than a Lamborghini). I have dealt with many such problems before and could coach you through the process but it would not be easy. I have attached a sample of the problems you will encounter if you try to compile this code on anything but an exotic Linux machine running Intel FORTRAN (which costs a fortune). I have been using REAL*16, *32, *64, *128, *256 since 1980, but I don't do it in FORTRAN. I use assembler that can be called from FORTRAN or C. I wrote a book on this subject, which happens to be free today https://www.amazon.com/dp/B09T3XR2W3 I don't know if this extended precision is essential for these calculations, but if it is, this will be a tall mountain to climb.
  • asked a question related to Programming in MATLAB
Question
6 answers
I am trying to programming fMRI (BOLD) data processing via SPM12 using MATLAB. I have four stimuli that each participant should note and respond according to each stimulus. When I want to set conditions for 1st-Level, in data some runs lack some stimuli (some of the stimuli have not been used). for example, there is no second-stimulus in run-2, but in others have been used.
Now, should I define an empty vector/zero value for "Onsets of the Condition" or in general I should not set a second-stimulus condition for run-2?
Relevant answer
Answer
Hello Amin,
just wonder if the empty array is still working for you?
With SPM 12 v. 7487 I get a message:
Item 'Onsets', field 'val': Size mismatch (required [Inf 1], present [0 0])
This suggests that at least in the somewhat recent SPM versions there is an internal check for the size of the onsets array.
  • asked a question related to Programming in MATLAB
Question
4 answers
Hi all,
I am trying to deploy neural network to a FPGA board mentioned in the question. So far I have succeed with simple projects provided by Mathworks such as:
and right now I would like to change images sent from PC to images from camera (ideally live video) connected directly to the FPGA board making it standalone machine, from image acquisition and preprocessing to image postprocessing.
Best example I found is:
But it requires a sister card which I don’t have, so before purchase I would like to explore other options. If its possible I would like to stick with Matlab/Simulink and HDL coder.
Thank you in advance.
Relevant answer
Answer
Recently I decided to abandon solutions provided by Mathworks and explore Xilinx tools. After some work with both Mathworks toolboxes and Vitis AI I would like to share my experience.
While Matlab and toolboxes that come with it seem easy to use on the surface, they are really badly described and overflowing with bugs. Moreover, the support provided by Mathworks is very poor and slow.
On the contrary, the Vitis AI environment is rich in detailed documentation. Something that took me a month with little to no success with the use of Matlab I accomplished in days with Vitis AI. Not to mention the far more helpful community that helped me solve issues in a matter of days.
With confidence I can say that Mathworks tools are not ready for the described type of applications.
  • asked a question related to Programming in MATLAB
Question
4 answers
In his name is the judge
Hi everyone
In order to use controller for structure with absorber, have to connect matlab and opensees in real time :
it means in each loop in opensees data must send to matlab and then matlab do some prossess with controller like fuzzy then send back data to opensees
Relying on researching and consulting the only way is use hybrid simulation (like openfresco),
do you have any other idea or way to connect these two programs without using openfresco?
Translation results
star_border
Consult
Wish you best.
Take refuge in the right.
Relevant answer
Answer
dear Eknara Junda thank you
i have to do optimization and design controller and for both of them i use matlab toolbox and i learned them fully, becuase of this i prefer to link matlab and opensees in real time.
  • asked a question related to Programming in MATLAB
Question
4 answers
In his name is the judge
Hi
can you say wich set of data is best to train and test ANFIS in matlab.
i mean how generate data to get less error, like nuber of data or Dissipation of them
Wish you best.
Take refuge in the right.
Relevant answer
Answer
thank you so much i'm going to try these.
  • asked a question related to Programming in MATLAB
Question
1 answer
After finishing the simulation of the cyclic peptide, I tried to find the most populated structure using the cluster peak density algorithm. from the literature, the representative structure was chosen as the structure with maximal ρsum (The summation of local densities of all residues in one structure, ρ𝑠𝑢𝑚 = ∑ ρ𝑖𝑛_𝑟𝑒𝑠𝑖=1) so how can I extract the structure which has the highest density for the all residue?
ref: Clustering by Fast Search and Find of Density Peaks. Science 2014, 344, 1492–1496
Relevant answer
Answer
Dear Sam Mohel ,
luster analysis is an exploratory analysis that tries to identify structures within the data.  Cluster analysis is also called segmentation analysis or taxonomy analysis.  More specifically, it tries to identify homogenous groups of cases if the grouping is not previously known.  Because it is exploratory, it does not make any distinction between dependent and independent variables.  The different cluster analysis methods that SPSS offers can handle binary, nominal, ordinal, and scale (interval or ratio) data.
Regards,
Shafagat
  • asked a question related to Programming in MATLAB
Question
3 answers
I am trying to plot 4 races on one polar plot using "hold on" command. the function I am using is "polar2". when plotting 2nd or 3rd trace, seems to create new axis (may be). the trace is extending.
Is there any other way to plot 2-3 plots in the same polar plot without using "hold on" command in Matlab?
Relevant answer
Answer
Meenakshi Kohli When calling nexttile, give the span option to produce a plot that spans many rows or columns. Make a 2-by-2 arrangement, for example. Plot the plot into the first two tiles. Then, make a plot with one row and two columns.
hold off toggles the hold state to off, which clears all existing plots and resets all axis properties when new plots are added to the axes. The next plot added to the axes employs the initial color and line style determined by the axes' ColorOrder and LineStyleOrder parameters. This is the standard behavior.
Using tiledlayout or subplot, you may display numerous plots in various regions of the same window. The tiledlayout function was added in R2019b and gives you additional flexibility over your labels.
  • asked a question related to Programming in MATLAB
Question
9 answers
ANY ONE HAS CLASSIFICATION EXAMPLE USING ANFIS?
Relevant answer
Answer
How can get probability of classification with ANFIS?
  • asked a question related to Programming in MATLAB
Question
5 answers
Hi everyone,
I want to extract the global mass and stiffness matrices of an Abaqus modal analysis, so as to post-processing it with Matlab.
I have already read many comments on RG regarding this question and added the following lines at the end of my Input file to get the mass and stiffness matrix.
*STEP
*MATRIX GENERATE, STIFFNESS, MASS
*MATRIX OUTPUT, STIFFNESS,MASS,FORMAT=MATRIX INPUT
*END STEP
So far, everything is fine.
I have also written Matlab code that works perfectly for 3D solids or shell elements, but not when both solid and shell elements are together.
In my model, I had to use both solid and shell elements in Abaqus. Looking at the mass and stiffness matrices, I saw that there are 3DOF per node for solid elements and 6 DOF for shell elements, so I cannot use the attached Matlab code as the model has 3DOF for solid elements and 6DOF for shell elements.
My mass matrix looks like this:
1,1, 1,1, 5.115770202111807e-10
1,2, 1,1, 4.923414202110917e-12
1,3, 1,1, -5.733085750203833e-15
2,1, 1,1, 1.453330463639921e-11
2,2, 1,1, -2.461707101055460e-12
2,3, 1,1, 2.866542875101822e-15
1,4, 1,4, 4.295511112920469e-14
1,5, 1,4, -4.054846090561977e-14
1,6, 1,4, -8.889774326370160e-16
2,4, 1,4, 1.225209356335630e-14
2,5, 1,4, -1.103358818158063e-14
2,6, 1,4, -4.552490123962178e-16
...
131010,1, 131010,1, 6.793914400596321e-08
131010,2, 131010,2, 6.793914400596321e-08
131010,3, 131010,3, 6.793914400596321e-08
131011,1, 131011,1, 7.423556175182037e-08
131011,2, 131011,2, 7.423556175182037e-08
131011,3, 131011,3, 7.423556175182037e-08
As you see here, some parts have 3DOF and some parts have 6DOF. Some parts are like a lumped and some parts are like a consistent mass matrix.
In this case, how can one use Matlab in order to get a global stiffness and mass matrices from this?
I've been struggling with this problem for a long time and still haven't been able to solve it.
Here, I am attaching both the mass.mtx file and the Matlab code.
Any help would be appreciated.
function [matlab_matrix] = import_matrix(mtx_file)
%============== Import Stiffness Matrix ==============%
abaqus_stiffness_matrix = dlmread(mtx_file);
% merge node number info from column 1 and DOF info from column 2 and
% store in the 1st column of a new matrix
%If number of DOF are 2,multiply by 2.
matlab_nodes(:,1) = 2*(abaqus_stiffness_matrix(:,1)-1)+ ...
abaqus_stiffness_matrix(:,2);
% merge node number info from column 3 and DOF info from column 4 and
% store in the 2nd column of a new matrix
matlab_nodes(:,2) = 2*(abaqus_stiffness_matrix(:,3)-1)+ ...
abaqus_stiffness_matrix(:,4);
% extract the stiffness values from the .mtx file, and store in a double
% length vector
stiffness_values = [abaqus_stiffness_matrix(:,5); ...
abaqus_stiffness_matrix(:,5)];
% create a matrix of the new matlab node numbers, and a vector of indices
% of their position in the abaqus stiffness matrix
[matlab_matrix_indices, abaqus_stiffness_value_index] = unique( ...
[matlab_nodes; matlab_nodes(:,2) matlab_nodes(:,1)], 'rows');
% compile the stiffness matrix using the new node numbering convention
matlab_matrix = accumarray( matlab_matrix_indices, ...
stiffness_values(abaqus_stiffness_value_index), [], @max, [], true);
Relevant answer
Answer
I wish you all the best I apologize that this is not my specialty
  • asked a question related to Programming in MATLAB
Question
4 answers
How can I generate all probability of non repeated combinations of .mat files?
For example there are the following mat files : One.mat , Two.mat , Three.mat
and each of these files contains 2 vector for example: One.mat contains V1 and V2 vectors, Two.mat: contains C1 and C2 vectors , Three.mat: contains D1 and D2 vectors.
So I want to generate the following combinations:
Comb1.mat contains: One.mat and Two.mat
Comb2.mat contains: One.mat and Two.mat
Comb3.mat contains: Two.mat and Three.mat
Comb4.mat contains: One.mat ,Two.mat and Three.mat
Is there any MATLAB code can help me to achieve this?
Note: I don't want to do this manually because there are many groups of mat files and I want to make a combinations of them and this will take time.
Relevant answer
You sent ma a notification that you solved the problem.
May I propose a solution?
The solution is as follows:
Assume that you have N files
Then you want to pare them uniquely
Then you can use the following formulation:
The combinations = SUM X1i with i=2 to N + SUM X2i with i= 3 to N+ SUM X3i with i=4 toN + .................+ SUM (N-1)N + SUM Xi with i from 1 to N.
Please tell me whether this solution satisfies your requirement or not.
Best wishes
  • asked a question related to Programming in MATLAB
  • asked a question related to Programming in MATLAB
Question
1 answer
Hi, recently I have developed the scalar reference governor in the Simulink by using the Matlab function block. Therefore, I have done me to develop the code, but there is a problem where the output of the system is not really track back the reference and has some undershoot. So I want ask for some help on how to improve this code or modified this code to make the output of the system become better. This is my output graph and the Simulink file is attached as follow,
This is my code
'''
function v = SRG_new(v_previous, r)
%state space eqaution of the closed loop system
A=[-21.22 1;-275.5 0];
B=[11.02;275.5];
C=[1 0];
D=0;
I=eye(2);
%Hx=(C*A);
%Hv= C*(I-A)*((I-A)^-1)*B;
e=0.05;
s=205; %s=max_y
k=1 ; % intialize k
S=100; %
%check the constrain,s is statisfied or not
for i=1:450
if S*(C*((I-A)^-1)*B+D)>(1-e)*s %first row of constriant not statisfied , k will decreases
k=k-0.00001;
else
if (S*C*A^i)+ S*(C*(I-A^i)*((I-A)^-1)*B+D)>s %second oand below row constriant not statisfied , k will decreases
k=k-0.00001;
else
k=k+0.00001; % if statisfied, k will increases
end
end
end
v=v_previous + k*(r-v_previous);
end
''''
Hope those experts in this field can give me help, really thx for the help.
Relevant answer
Answer
I recommend using Micro-Cap (http://www.spectrum-soft.com/download/download.shtm). All EE's at Emerson used Micro-cap, even though it cost $4,000 each. There are no other electronic SPICE modeling programs even close to Micro-Cap capability.
Micro-Cap is now free. Andy Thompson, owner of Spectrum Software, has retired.
Micro-Cap does worst case analysis --- changing the tolerances of components --- changing the temperature --- etc. And it is easy to use.
I have used Micro-Cap for all of my electronic designs since 2001. When I tested prototypes, they worked exactly as the model predicted.
The website --- https://NDAcademy.FoxPing.com/ --- 2.8 Electronic Cascade RC Filters --- and --- 7.2 Electronic SPICE Models --- provide examples.
  • asked a question related to Programming in MATLAB
Question
4 answers
Dear Friends,
I would like to know about the best method to follow for doing MATLAB based parallel implementation using GPU of my existing MATLAB sequential code. My code involves several custom functions, nested loops.
I tried coverting to cuda-mex function using MATLAB's GPU coder, but I observed that it takes much more time (than CPU) to run the same function.
Proper suggestions will be appreciated.
Relevant answer
Answer
MATLAB may launch a parallel pool automatically based on your selections. To enable this option, go to the Home tab's Environment group and click Parallel > Parallel Preferences, followed by Automatically build a parallel pool. Set your solver to parallel processing mode.
Make a row vector with values ranging from -15 to 15. Use the gpuArray function to move it to the GPU and build a gpuArray object. To work with gpuArray objects, use any MATLAB function that supports gpuArray. MATLAB uses the GPU to do computations automatically.
To start a parallel pool on the cluster, use the parpool function. When you do this, parallel features like parfor loops and parfeval execute on the cluster workers. If you utilize GPU-enabled functions on gpuArrays, the operations will be executed on the GPU of the cluster worker.
  • asked a question related to Programming in MATLAB
Question
1 answer
How can I have water-LiBr mixture properties in MATLAB library?
Relevant answer
Answer
One possibility would be to link Matlab with Refprop. More information can be found in the following sources:
GitHub - jowr/librefprop.so: Create a shared library from the Fortran sources provided by Refprop from NIST. This project provides an alternative to the refprop.dll that comes with the software. Please use the official instructions if possible
  • asked a question related to Programming in MATLAB
Question
5 answers
How can you share the programs and codes-like MATLAB code- which you have used in your paper. so that you can reference them scientifically? is there any scientific journal to do it for free?
Relevant answer
Answer
Mostafa Shabani you can share your coding using GitHub.com. You need to get an account there then upload your code publicly
  • asked a question related to Programming in MATLAB
Question
9 answers
sleepSMG is now running on matlab.
Then I created a 64-channel tarumi_Montage and tried to load the data file into sleepSMG, but I get the following error.
How can I load it?
If possible, I would appreciate it if you could give me a concrete example of using sleepSMG.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<
error: tarumi_Montage (line 6)
EEG = handles.EEG;
error: plotSleepData (line 9)
eval([plotFCN{boxInd}, '(handles, range);']);
error: sleepSMG>plotSleepIN_Callback (line 1083)
plotSleepData(handles, range)
error: gui_mainfcn (line 95)
feval(varargin{:});
error: sleepSMG (line 45)
gui_mainfcn(gui_State, varargin{:});
Error while evaluating uicontrol Callback
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Relevant answer
  • asked a question related to Programming in MATLAB
Question
19 answers
Hi. I'm working on 1000 images of 256x256 dimensions. For segmenting I'm using segnet, unet and deeplabv3 layers. when I trained my algorithms it takes nearly 10 hours of training. I'm using 8GB RAM with a 256GB SSD laptop and MATLAB software for coding. Is there any possibility to speed up training without GPU?
  • asked a question related to Programming in MATLAB
Question
3 answers
Hi
I am planning to reconstruct 3D geometries of coronary arteries from angiogram images (not a single artery whole coronary artery trees). I am wondering if any of you have any software suggestions that can help. Or any potential Matlab/Python codes that can help?
I know that there is some open-source software that can be used for CT or MRI images. But I couldn't find any for angiogram images.
Thanks for your help.
Navid
  • asked a question related to Programming in MATLAB
Question
3 answers
Hi
I intend to define a frequency domain objective function to design an optimal controller for Load-Frequency Control (LFC) of a power system. My purpose is to optimize this objective function (finding the proper location of zeros and poles) using meta-heuristic methods.
I will be happy if you share your valuable relevant and informative experiences, references and articles in this field including how to define and how to code.
Thanks
  • asked a question related to Programming in MATLAB
Question
3 answers
I have 6 variables with Mean, Stdev, CoV, Min and Max. Find the attached excel file.
Relevant answer
You may use the approach for regression analyses. That should work.
  • asked a question related to Programming in MATLAB
Question
6 answers
The forecast error determined by the probability density function (PDF) of the system forecast error can be used to model uncertainty. Monte Carlo sampling (MCS) and simulation generate a number of solar irradiances and load demand scenarios. The greater the number of generated scenarios, the more complicated the computation and the longer the convergence response time. As a result, this study used a K-means clustering-driven scenario reduction scheme to reduce the generated scenarios in reduced scenarios while preserving a precise estimation of the uncertainty.
Is there a manuscript or book where these concepts can be learned, or any MatLab/python code where they can be understood?
Relevant answer
Answer
Montecarlo is a simple technique...let me explain you in steps:
1) First, you need to have a probability density function of uncertain parameters (solar, load).
2) Let us say the load is modeled as a normal distribution; this means you know the mean and standard deviation of it.
3) You can then generate random numbers based on the above information. random('norm',mean,std.,1000) 1000-> reqd. number of samples (say) in MATLAB. So, now you have 1000 random samples of load.
4) You can do the same step for solar irradiance where the only difference is the irradiance is commonly modeled as a beta distribution....so use random('beta', a,b,1000) where a and b are shape parameters
5) You can use the Gaussian Copula method to generate correlated random numbers if you want (sometimes solar and load can be correlated)
The above steps are not Montecarlo but let's say you want to analyze the impact of uncertain parameters on the voltage of your test system. Then, you can use the generated random samples to calculate voltage values (1000 as the total sample numbers) using load flow.
So, once you have 1000 samples of voltage, you can find the expected value and variance of the voltage and get the statistical information about it or even create a probability function if you want. Now, the overall method is called the Montecarlo simulation for voltage assessment.
I think in your case, you just need to follow steps 1-4 and then use the clustering method to provide the most occurring scenarios (which will depend on the number of clusters you decide ofcourse)
Samundra
  • asked a question related to Programming in MATLAB
Question
9 answers
Hello everyone,
I am having stability problems implementing anisotropic material in my FDTD code and I cannot find where I am doing it wrong. I'm trying to implement the code for anisotropy in the XY direction and have sigma-xy and sigma-yx as my off-diagonal elements in the electrical conductivity matrix. also, I attach a picture of the updating equation for Ex both in half-space and matrix form to understand how it updates the Ex. In the code, I calculate the fields caused by anisotropy in an auxiliary matrix where the anisotropic material exists and add that to the main updating equation. I also attach the portion of the code used for updating the Ex to give me your opinions about my approach. Any help or hint would be greatly appreciated.
By the way, I have checked the equations and the code for any flaws multiple times, but nothing was typed incorrectly and everything was fine concerning the possible mistakes in writing.
Relevant answer
Answer
Reference of the code:
  • asked a question related to Programming in MATLAB
Question
4 answers
how to calculate number of computations and parameters of our customized deep learnig algorithm designed with MATLAB
Relevant answer
Answer
  • asked a question related to Programming in MATLAB
Question
10 answers
Hi. I'm doing a classification problem using deep learning. so that need to train 512x512 images but when i trained my algorithm shows out of memory error. I want to know how much memory size needed to train 512x512 images in MATLAB.
Relevant answer
Answer
Dear Srinivas:
For classification and regression tasks, you can train various types of neural networks using the trainNetwork function.
i.e. you can train:
-- a convolutional neural network (ConvNet, CNN) for image data.
-- a recurrent neural network (RNN) such as a long short-term memory (LSTM) or a gated recurrent unit (GRU) network for sequence and time-series data
-- a multilayer perceptron (MLP) network for numeric feature data.
You can train on either a CPU or a GPU. For image classification and image regression, you can train a single network in parallel using multiple GPUs or a local or remote parallel pool. Training on a GPU or in parallel requires Parallel Computing Toolbox™. To use a GPU for deep learning, you must also have a supported GPU device. For information on supported devices, see GPU Support by Release (Parallel Computing Toolbox). To specify training options, including options for the execution environment, use the trainingOptions function.
When training a neural network, you can specify the predictors and responses as a single input or in two separate inputs.
Thus, the entirety of this process depends mainly on the properties of these two hardware (cpu or Gpu).
I hope it will be helpful..
With my best wishes ...
  • asked a question related to Programming in MATLAB
Question
5 answers
Hi 
What frequency specification should I use in order to create a low-pass filter (specifically filter order and Frequency specifications)? I have a huge data set which contains unfiltered water level data and it is in meters relative to mean lower water (MLW) at hourly intervals. The time stamp is in Julian data. 
thank you in advance. 
Relevant answer
Answer
Welcome!
Sure you found a solution but I have a proposal that may help solve such problems.
At first one has to draw the wave profiles as w(x,t)
There are two waves, time waves at certain position.
And there is also position waves.
At first you can analyze these waveforms using Fourier transform such as fft.
After which you may decide on the low pass filter characteristics by setting the cut off frequency and the stop frequency and the stop band attenuation.
Then give such specifications one can design the low pass filter. either analog of digital.
Best wishes
  • asked a question related to Programming in MATLAB
Question
10 answers
when i use interpolation sweep, the option of sweep is hidden from this box. why?
  • asked a question related to Programming in MATLAB
Question
2 answers
Does anyone have the codes (written on RATS/MATLAB/any other platform) for Rolling Hinich Bicorrelation test and Rolling Hurst Exponent test? Would greatly appreciate if you could share them.
Relevant answer
  • asked a question related to Programming in MATLAB
Question
11 answers
Hello,
I am working on my research and looking for an IoT simulator environment or software to provide the following capabilities or provide integration to other tools to provide capabilities.
I have already looked at NS-3 briefly and NetSim.
- IoT network system with simulation of different IoT architecture such as Star or Mesh
- AI including Reinforcement learning capabilities
- Monitoring and capturing network activities/packets
- Cyberattack scenario simulation
- Possible 5G capabilities
Appreciate your help,
Thanks,
Anthony
Relevant answer
Answer
Dear Anthony:
I agree with all the answers given and recommend it, but i would like to add the following:
Here's a list of the best IoT testing and Simuling tools:
1- IoTIFY:
aims to ease the life of IoT developers and testers by providing simulation as a service. Their platform lets you define a virtual device and specify the connection endpoint, and they will handle the running and scaling the simulation as you need.
Protocols: MQTT, HTTP REST or CoAP.
Pricing: Contact IoTIFY directly for a quote.
2- BevyWise IoT Simulator:
helps you test your cloud and on-premise MQTT Application for functional and load testing. You will be able to simulate tens of thousands in a commodity server. You will be able to develop and test all aspects of your IoT devices from servers to MQTT devices.
Protocols: MQTT, REST.
3- MATLAB Simulink:
help you design and prototype IoT applications such as predictive maintenance, operations optimization, supervisory control, and more.
Protocols: REST, MQTT, and OPC UA.
4- IBM Watson IoT Platform (IBM Bluemix):
it's a solution of various IBM Cloud services. The IoT platform lets you collect and analyze relevant product performance and usage data for your IoT enabled assets.  There are also add-ons that can be added to the platform such as Blockchain or Platform Analytics.
Protocols: MQTT and HTTP REST.
5- NeoLoad:
It's a great straight out of the box option for mobile load testing and IoT use cases. You can quickly and efficiently create tests that accurately represent your real users regarding network conditions, specific devices, and geographic locations. You will be able to record any native or otherwise mobile app direct recording from any device or emulator.
6- IoT Performance Testing Tools
LoadRunner:
supports a wide range of apps. It helps you drastically reduce the amount of time and skill required to simulate user transactions in load testing software. And with integrations with a lot of different IDEs and support for testing scripts it allows for continuous testing. LoadRunner also helps you identify performance bottlenecks by using seamless integrated real-time performance monitors.
I prefer this one ....
7- LOCUST:
is an open-source load testing tool that uses Python code. Locust supports running load tests distributed over multiple machines this allows for the simulation of millions of devices and users. It’s a tried and tested option and being open source and uses python makes it very accessible.
I hope it will be helpful...
With my best wishes...
  • asked a question related to Programming in MATLAB
Question
5 answers
I have an experimental set of data ( xdata, ydata) and I want to fit a 5 constant expression to these data and find the unknown constants with following matlab built in function :
[q,resnorm,residual,EXITFLAG,output,LAMBDA]=lsqnonlin('fun',q0)
it converges. but the norm is too big and as of "q", it returns my initial guess as the final fit
. I checked my procedure with some other set of data and a different function, it works perfectly. does this mean that the initial guess is too far? any suggestions? 
thanks in adavance
Relevant answer
Answer
Often the nonlinear correlation to be fitted to data can be 'somehow' linearized, as a first stage. Linearized correlation and the corresponding linearized plot are often quite convenient to qualitatively evidentiate scattering around the trendline and to emphasize major effects and the physical meaning of the correlation parameters. Estimates of the parameters derived by least squares after the linearized correlation (modified from a former nonlinear correlation) can possibly be refined by iterative nonlinear least-squares regression; to find unbiased least-squares estimates for the original correlation. It may be advisable to compare both the linearized and the nonlinear correlations.
The following RG discussions seemingly can be found of some interest, concerning to your query:
  • asked a question related to Programming in MATLAB
Question
10 answers
I am trying to estimate the width of DNA from its crystal structure.
Relevant answer
Answer
Hi can you share the notebook ?
  • asked a question related to Programming in MATLAB
Question
4 answers
Kindly refer to the question.
Relevant answer
Answer
Yes, you can import data (or copy/paste) as matlab variable. Then you can use it with FIS.
  • asked a question related to Programming in MATLAB
Question
4 answers
Hello everyone!
I am trying to write a long objective function (below) in MATLAB but I could not write the summations and the squared term (x_ptsk, which is a decision variable).
Is writing a function necessary int his case or can I completely write the objective function in my main code?
Also, the a and b values in the objective function are lower and upper limits for a uniform distribution and have three indices (p,s,q) which I pre-defined the values in another function. How can I implement the indices in the function?
Thank you so much in advance and best regards.
Relevant answer
Answer
please have a look at the following code (on YALMIP) which can be found on
u = sdpvar(repmat(nu,1,N),repmat(1,1,N)); constraints = []; objective = 0; x = x0; for k = 1:N x = A*x + B*u{k}; objective = objective + norm(Q*x,1) + norm(R*u{k},1); constraints = [constraints, -1 <= u{k}<= 1, -5<=x<=5]; end
you define a vector for the set that you have(e.g. \forall x_ \in X, make a vector x and then you can write
sum(X) => gives you sum of all the items that you have in your set (X)
I think you are looking for sth similar to the following code
constraints = [];
objective = 0;
summation_1 = 0;
x = x0;
for k = 1:N
x = A*x + B*u{k};
objective = objective + norm(Q*x,1) + norm(R*u{k},1);
summation_1 = summation_1 + % ... => after the for you have the summation of what you are looking for
constraints = [constraints, -1 <= u{k}<= 1, -5<=x<=5];
end
  • asked a question related to Programming in MATLAB
Question
4 answers
Hi everyone,
Does anyone know how to execute the following script using NCO. Please refer the attached link for the script. 
Thanks. 
Relevant answer
Answer
How to in files not exist time dimension?
  • asked a question related to Programming in MATLAB
Question
3 answers
Hello
that is, so that I would like to implement a network that consists of 16 nodes (see the figure below) after I have implemented it, I want to combine the network with a heuristic and it becomes the nearest neighbor heuristic. Given that I have the costs between the nodes. The vehicle in the middle should travel and represents the shortest route.
How can I proceed? Can anyone help me how I can implement a network and combine the heuristics in it using matlab or java.
  • asked a question related to Programming in MATLAB
Question
2 answers
I would like to implement a network that consists of few nodes (see the figure below) after I have implemented it, I want to combine the network with a heuristic and it becomes the nearest neighbor heuristic. Given that I have the costs between the nodes. The vehicle in the middle should travel and represents the shortest route.
How can i code it ? Need a code for implement a network and combine the heuristics in, using matlab.
I approximately found a code below that matches my problem (see figur ) but the code counts the nearest neighbor directly but I want to divide the task myself and then it will count the nearest neighbor
Relevant answer
Answer
Based on the available code, make the following modification:
Define a weighted distance as the function of the costs. The rest of the code is suitable for your objective.
But, about dividing tasks, it is a little ambiguous. Please explain more.
  • asked a question related to Programming in MATLAB
Question
3 answers
Hi,
I want to develop an algorithm to recognise arabic (moroccan) plate, so i use openalpr library with tesseract. My question is how to train alpr-ocr to recognise arabic plate?
Relevant answer
Answer
you can use the dataset here to train your model https://msda.um6p.ma/msda_datasets
  • asked a question related to Programming in MATLAB
Question
3 answers
Relevant answer
Answer
Good question.
  • asked a question related to Programming in MATLAB
Question
6 answers
I need to write a MATLAB code that has the ability to process a GIS image in order to extract the coordinates of the grid points within the red region (R) and that are at least distance "d" from its boundary. Each point in the R is given a weight w1 (attached figure). The same procedure is to be made for the green region (G) but w2 is the weight of any point in G. The gathered data are saved in a matrix formed of three rows: row 1 contains the abscissa, row 2 contains the ordinate, and row 3 the weight.
I am looking forward to getting your suggestions...thanks in advance.
Relevant answer
Answer
im=imread('GIS.jpg');
%imshow(im);
BW = im2single(im);
numclust=5;
[L,Centers] = imsegkmeans(BW,numclust); % matlab inbuilt
temp_mask = L==1;
figure,imshow(temp_mask);
might help:)
  • asked a question related to Programming in MATLAB
Question
11 answers
I am using MATLAB's  'fmincon' to solve some nonlinear constrained optimisation problem. But it is very slow. What are the possible ways to speed up the simulation?
What is the best alternative to 'fmincon' to speed up the optimisation process so that I can use it with MATLAB? 
Relevant answer
Answer
In the Matlab page of fmincon mentioned that a parameter to speed up as follows:
UseParallel
"When true, fmincon estimates gradients in parallel. Disable by setting to the default, false. trust-region-reflective requires a gradient in the objective, so UseParallel does not apply. See Parallel Computing. "
  • asked a question related to Programming in MATLAB
Question
7 answers
Base radius is the interface of the liquid and the solid surface. Contact angle is just the angle a droplet makes with the surface at the triple point.
Relevant answer
Answer
Hossein Safari I'm interested in it!
  • asked a question related to Programming in MATLAB
Question
5 answers
This...
str = 'ones';
function_handle = str2func(str)
function_handle(1,5)
...does not work for methods defined within a class.
Is there an alternative solution?
Thank you
Relevant answer
Answer
Thank you
  • asked a question related to Programming in MATLAB
Question
2 answers
I have a thesis on Utilize the electrical power from Regenerative Braking in 750 Vdc Traction by simulation in the Program MATLAB Simulink. I made the Power Load flow from 24kV to Traction Transformer and Rectifier to supply 750 Vcd but how to do it next on the supply regenerative power back in the source which to be up the voltage to 840 Vdc in the simulation.
Relevant answer
Answer
I understand according to your question that you want to reduce the stress in simulation to get reasonable results,
I advise you to put a resistance in series (proportional to the required voltage) to get a source voltage = 750VDC
  • asked a question related to Programming in MATLAB
Question
34 answers
Good morning everyone. As a part of my research work, I designed a network that extracts the leaf region from the real field images. when I search about performance evaluation metrics for the segmentation I found a lot of metrics. Here I provided the list
1. Similarity Index = 2*TP/(2*TP+FP+FN)
2. Correct detection Ratio = TP/TP+FN
3. Segmentation errors (OSE, USE, TSE)
4. Hausdorff Distance
5. Average Surface distance
6. Accuracy = (TP+TN)/(FN+FP+TP+TN);
7. Recall = TP/(TP+FN);
8. Precision = TP/(TP+FP);
9. Fmeasure = 2*TP/(2*TP+FP+FN);
10. MCC = (TP*TN-FP*FN)/sqrt((TP+FP)*(TP+FN)*(TN+FP)*(TN+FN));
11. Dice = 2*TP/(2*TP+FP+FN);
12. Jaccard = Dice/(2-Dice);
13. Specitivity = TN/(TN+FP);
14. Sensitivity = TP/(TP+FN);
suggest to me which performance evaluation metrics are best suited for my work. thank you.
Relevant answer
  • asked a question related to Programming in MATLAB
Question
5 answers
Can anyone recommend a good code/software/implementation to identify the change of molecules (bond creation/break, number of molecules at a given timestep, etc.)? I am currently working with XYZ XDATCAR PDB LAMMPS data files.
Thank you!
Relevant answer
Answer
I had similar issues with my work, simulating water and hydroxides.
Most programs for visualization/analysis tend to use fixed connectivity, and typing.
In VMD e.g., you can script reading an array of bonds before every frame, I've used TCL and TOPOTOOLS.
You can also use "user" variables for dynamic typing.
This was good for visualization, but not good for analysis.
At the end, I switched to MDAnalysis:
in MDA you can write a python function which runs before every frame, either computing the connectivity or reading it from a file/array.
  • asked a question related to Programming in MATLAB
Question
6 answers
function cmatrix = ccoeffunction(region,state)
n1 = 9;
nr = numel(region.x);
cmatrix = zeros(n1,nr);
cmatrix(1,:) = ones(1,nr);
cmatrix(2,:) = 2*ones(1,nr);
cmatrix(3,:) = 8*ones(1,nr);
cmatrix(4,:) = 1+region.x.^2 + region.y.^2;
cmatrix(5,:) = state.u(2,:)./(1 + state.u(1,:).^2 + state.u(3,:).^2);
cmatrix(6,:) = cmatrix(4,:);
cmatrix(7,:) = 5*region.subdomain;
cmatrix(8,:) = -ones(1,nr);
cmatrix(9,:) = cmatrix(7,:);
I created a function for c coefficient in PDE toolbox using the above example given in MATLAB documentation. My problem is a system of parabolic equations. I want to make sure that parabolic non linear system of PDE can be solved using PDE toolbox in MATLAB. However when I write the state.u as mentioned above error shows up: Function handle specifying a coefficient must accept two input arguments and return one output argument.
Relevant answer
Answer
Dear Aditi Chauhan:
Could you please guide me, How you resolved this error finally?
"Function handle specifying a coefficient must accept two input arguments and return one output argument."
I have the same error.
  • asked a question related to Programming in MATLAB
Question
5 answers
I am using feed-forward neural networks for stock prediction, but i am getting problems on training function (pre-define in matlab). Its about input/output size. I set it regarding to function instruction (given in tool), but do not get results.
Relevant answer
Answer
Look the book, maybe useful.
Regards,
Shafagat
  • asked a question related to Programming in MATLAB
Question
3 answers
Hello everyone,
Has anyone ever succeeded in calculating the energy reflection coefficients in LAMB wave edge reflection problem? Or any available code resources?
I am a third-year master student majored in solid mechanics. I have been stuck with the energy conservation problem for so long now.
Dispersion curves, mode structures, and power flux of individual mode are consistent with the results from the software DISPERSE. However, the sum of energy reflection coefficients did not equal 100%, even in the normal incident edge reflection case with a single layer isotropic plate.
By comparing with results from different resources (details can be seen in CodeValidation.png), the correctness of my SCM method should have been validated, as shown in figs. 1-3.
However, the energy reflection coefficients just didn't sum to 100%. As shown in fig.4, the A0-A0 energy reflection coefficients ​matches with Gunawan's results, but A0-A1 energy reflection coefficients​ failed to match. That's wierd but I can't find the causes.
I am wondering if I have treated the wavenumber k in a wrong way:
  1. For LAMB waves propagating in +x direction, the displacement field was assumed as u = U*exp(i(kx-wt)). The numerically obtained k may have the form a + bi, a - bi, -a + bi, -a - bi (a and b are positive real numbers). In the GetkInOrder.m, I have kept only those with positve real part (+x propagating) and positive imaginary part (physically decaying with propagation).
  2. For LAMB waves propagating in -x direction, the displacement field was assumed as u = U*exp(i(-kx-wt)), so the k will be still kept k = a+bi (a>0 and b=0; or a=0 and b>0 ).
Am I wrong about the selection of calculated wavenumber k? Maybe it is the error in this step that makes the energy conservation cannot be met?
The same problem is met while calculating the excitability, which is defined as the parameter that relates the amplitude of the excitation force and the modal response of a particular mode at a specific frequency.
I have emailed many authors who have published papers about this topic with their articles, my codes, and detailed ideas of my codes and method; however, most of them did not reply while others can not help me.
I understand that every program is hard-won and they have no duty to help me. But this problem is really important to me. I have been stuck for months and I am still trying.
If there is anyone who has ideas about how to fix this problem, please help me. Thank you so much.
Best wishes,
Hao Qiu
Relevant answer
Answer
I think when you calculate scattering coefficients, you should classify modes according to sign of group velocity.
Even if phase velocity is positive, group velocity is not always positive.
For example, group velocity of S1-mode near the cut-off frequency is negative.
  • asked a question related to Programming in MATLAB
Question
4 answers
Hi!
For my master's thesis I'm surveying the community of users of MATLAB and similar languages (Octave, Scilab, Rlab, etc.). The main goal is to document the different ways these languages are being used and to gather opinions and feedback that the users might have about these languages and their features (such as object-orientation).
It doesn't matter if you're only a complete beginner or if you're an expert, your response helps the study! So if you could spare just a couple of minutes to participate, it would help us immensely.
Additionally, if you have any feedback or any information that you think could be relevant for this study feel free to comment below.
Thank you! 
Relevant answer
Answer
Do not forget to put there Python. It is used by many scientists across all disciplines. Additionally, it is the main language with libraries used in AI and machine learning: libraries like SciPy, NumPy, etc.
  • asked a question related to Programming in MATLAB
Question
17 answers
Hi everyone,
I have some variables in my code that are a function of other variables. For example assume that Q is a variable which is a function of q1,...q4. ( Q= f(q1,q2,q3,q4) ).
When I calculate Q, since its characters exceed 25000, I have to store it in a text file. When I copy the obtained Q value in a word document, I see that it exceeds 1300 pages (yes, one thousand and three hundred pages)!!
When I want to copy this text file in a Matlab script file it gives me an out of memory error. I need to use the Q in every iteration of my code and in each iteration q1,...q4 change.
How can I use such a big value in my code?
Relevant answer
Answer
  • asked a question related to Programming in MATLAB
Question
7 answers
I am doing my project work in snowmelt runoff modelling. I have collected a Matlab code which I found very difficult to understand due to its complexity.
Relevant answer
Answer
  • asked a question related to Programming in MATLAB
Question
4 answers
Hi!
For my master's thesis I'm surveying the community of users of MATLAB and similar languages (Octave, Scilab, Rlab, etc.). The main goal is to document the different ways these languages are being used and to gather opinions and feedback that the users might have about these languages and their features (such as object-orientation).
It doesn't matter if you're only a complete beginner or if you're an expert, your response helps the study! So if you could spare just a couple of minutes to participate, it would help us immensely.
Additionally, if you have any feedback or any information that you think could be relevant for this study (such as where else I could share this survey) feel free to comment below.
Thank you! 
Relevant answer
Answer
I have used MATLAB to code psychophysical experiments and execute them, while simultaneously communicating with 3-4 different measurement equipment (2 were analog and 2 were digital) through the use of an analog and a digital DAQ, collecting the data from all these devices, controlling their behaviour, and storing the data in csv/text files, all on a custom made GUI with the press of a button.
I love MATLAB.
  • asked a question related to Programming in MATLAB
Question
21 answers
Recently, I was faced with a new error in MATLAB. It says "Out of memory." I think there should be a way to increase it's memory. Any suggestions?
Relevant answer
Answer
Why are you still using 32 bit?
  • asked a question related to Programming in MATLAB
Question
14 answers
Dear friends:
While one can easily write an *.m file for implementing a sliding mode control,
for example, to stabilize a control system, integral sliding mode control is also
a popular scheme and used in many papers.
I like to know how to write an *.m file for implementing integral sliding mode control?
I like to kindly request Sliding Mode Control (SMC) experts to illustrate this control
and MATLAB code with a simple example of a control system on the plane (with twostates x1, x2) and how to set up the integral sliding mode control in MATLAB.
Thanks a lot!
With best wishes, Sundar
Relevant answer
Answer
1-IMPROVED INTEGRAL SLIDING MODE CONTROL METHODS FOR SPEED CONTROL OF PMSM SYSTEM
By: Cunjian Xia, Xiaocui Wang, Shihua Li and Xisong Chen
  • asked a question related to Programming in MATLAB
Question
19 answers
I fit my data in MATLAB with a function and I can see the results and coefficients in the command window. I need this coefficient in order to continue with my codes, but
I can't input this coefficient in my codes, or I can't use the result in my codes.
Relevant answer
Answer
  • asked a question related to Programming in MATLAB
Question
3 answers
Implementing udwt in matlab . Which is the function or corresponding loc(lines of code)
Relevant answer
Answer
UDWT (undecimated discret wavelet ) in matlab:
Regards
  • asked a question related to Programming in MATLAB
Question
6 answers
Hello,
I am comparing different techniques (Current Injection (Already calculated), Newton Raphson (Already Done), and Backward-Forward Sweep (facing problem)) for load flow analysis for three phase unbalanced system though Matlab.
From couple of weeks, I have tried to develop matlab code for Backward-Forward sweep but failed. It will be great help if I get code (even general/conventional method will be very helpful for me) for backward-forward sweep for three-phase (not single phase).
Looking forward for your help. Thanx.
Cheers,
Muhammad  
  • asked a question related to Programming in MATLAB
Question
9 answers
i design a neural network based WSN to achieve real time operation, i simulate the part of neural in matlab and the issue of WSN in a network simulator. how can i start with neural part?
and is there any effect in the design of neural network due to using it in a WSN?
thanks
jannat
  • asked a question related to Programming in MATLAB
Question
8 answers
Matlab code for State Space analysis of Doubly Fed Induction Generator?
Relevant answer
Answer