Answered
Modelling of Disease using SEIR Model with Genetic Algorithm
‘However, I got negative values for the x output, beta, which is not supposed to happen.’ The ga function does not know that....

4 years ago | 0

Answered
Zero Pad My FFT Signal and Window
I recognise my code! I see nothing wrong with that (although I do not understand the two fft calls), however I would change i...

4 years ago | 0

| accepted

Answered
Looping a regression for 30 different observations 10 times
One approach — xa = randn(300,3); ya = randn(300,1); forstep = 30; for k = 1:forstep:size(xa,1)-forstep idxrng = k:k+3...

4 years ago | 0

| accepted

Answered
How do I predict x for a given value of y using glmval?
Using code from the documentation as an example — x = [2100 2300 2500 2700 2900 3100 ... 3300 3500 3700 3900 4100 4300]'...

4 years ago | 0

| accepted

Answered
Doesn't Match legend color and plot color
There are several lines created for the first plot call. Return handles to each plot call and then choose the first line of eac...

4 years ago | 1

| accepted

Answered
How can I make exponential function visible
One option would be to create at lelast the y-axis scale as logarithmic — X = linspace(0, 1, 50); Y = exp(-10^18* X); figu...

4 years ago | 0

Answered
how i can evaluate LTI system on matlab
You will need the Control System Toolbox to evaluate it.

4 years ago | 0

Answered
Inner matrix dimensions must agree error in ga
There is only one parameter, however it has two conflicting constraints. The constraints are: Unless there is something...

4 years ago | 0

| accepted

Answered
how to obtain peak time
I am not certain what the problem is with what you want to do, however the text function could be a solution.

4 years ago | 0

| accepted

Answered
Is there a way to update the legend as the for goes on?
See the legend documentation section on Specify Legend Labels During Plotting Commands for one possible approach x0 = 10; t =...

4 years ago | 0

Answered
estimation of parameters by using lsqnonlin for system of differential equations
I recognise my code. It should have the correct lsqcurvefit call, so all you need to do is substitute your differnetial equat...

4 years ago | 1

Answered
How to test whether two arrays are statistically different?
I would plot them with surf and then look at each separately and then both together, depending on what they are (here, plotting ...

4 years ago | 1

| accepted

Answered
How do i delete red box?
You forgot one semicolon. That is the one following the function call itself: A=work5(x); Add it, and the problem should b...

4 years ago | 0

| accepted

Answered
How do I get damping constant and periods duration of my damped oscillation
The approach in Calculate time period of a graph signal is one option. That code assumes an exponential envelope, so it will be...

4 years ago | 1

Answered
Solve function:Error using sym/solve>getEqns
Looking at the documentation for qfunc it is straightforward to create a symbolic version — syms B symqfunc(x) M= 1024; sym...

4 years ago | 1

Answered
How to define the model in a genetic algorithm when some model parameters are to be searched by the algorithm?
To pass extra parameters to the fitness function, and optimise only the parameters-of-interest (here ‘p’), do something like thi...

4 years ago | 0

Answered
Count the number of equal and different occurrences in an array
Use unique on the last two columns, then accumarray to sum the occurrences — A = [1 0 0 2 0 0 3 1 1 4 0 1 ...

4 years ago | 0

| accepted

Answered
How do I use fprintf to print a cell in a cell array?
Use curly braces {} to address the cell array: c = {"Hi"}; % String Variable fprintf('%s'...

4 years ago | 0

Answered
How to put word in the matlab function?
Use the strcmp or strcmpi function to compare character arrays: if strcmp(typein,'abs') && strcmp(typeout,'abs') Do this si...

4 years ago | 0

Answered
How to show all xtick labels in a barplot?
Try this — mydata = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/948329/bardata.csv'); mydata_so...

4 years ago | 2

| accepted

Answered
Defining a mathematical function as the summation of multiple functions
To get all the arguments as elements of a single vector. use the 'Vars' name-value pair and enclose the arguments in square brac...

4 years ago | 0

| accepted

Answered
How can I convert a function with multivariable input to a function with single vector input?
Do essentially the same thing, creating it with another anonymous function around it — fun2 = @(x,y) x^2+y^2; fmincon(@(b)fun...

4 years ago | 1

Answered
Plotting vectors with different values on each other
One approach — Data = randn(5, 25); % Create Data Matrix x = 0:size(Data,2...

4 years ago | 0

Answered
for loop with ode45 function
Put the reference in the ‘f’ argument list: [t,z] = ode45(@(t, z) f(t,z,k_l(ii),disp_data,vel_data,t_data),T,IC); ...

4 years ago | 0

| accepted

Answered
how to sum different rows within a column
One approach would be to create the third column independently and then concatenate it at the end — A = randi(9,10,2); p = 0;...

4 years ago | 0

| accepted

Answered
How to Plot the smooth envelope of 3D scattered points
See if the boundary function offers an improvement.

4 years ago | 0

Answered
How do you save a graph object?
The graph objects themselves can likely be saved to a .mat file using the save function. The plots of the graph objects are i...

4 years ago | 0

| accepted

Answered
getting and printing data from matrix
I am not certain what the original matrix structure is, so I am taking some liberties with it. Works = [5 8 9 15 7 12...

4 years ago | 0

| accepted

Answered
How to restore MATLAB warnings to factory default?
See if the documentation section on Restore Warnings will do what you want.

4 years ago | 0

Answered
How to bold in a sprintf function?
You can do that in a a text call (with any text objects, such as title, xlabel, etc.), nowhere else. m = pi; b = exp(1); t...

4 years ago | 1

| accepted

Load more