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

Answered
How to create a vector whose elements are functions of a variable?
This term: sum(TmdFOURIER_TERM(dphi)) needs to be defined as a function with its argument in order to evaluate it. Nmmaxd ...

4 years ago | 0

| accepted

Answered
Why doesn't my figure(2) display anything?
Either re-define ‘a’ or make ‘b’ a function of ‘a’ instead of ‘x’. %problem: f(x)= -3x^4 + 10x^2 - 3 %one plot for -4 <= x...

4 years ago | 1

| accepted

Answered
How to filter a signal that just some special frequencies can be passed?
A reasonably efficient way of doing this is to use a multiband FIR filter, for example — Fs = 1000; ...

4 years ago | 0

Answered
How to read a set of numerical characters for time and date
To just get the dates and times, try something like this — timechar = {'14442940912210', '14443040912210', '14443140912210', '...

4 years ago | 0

| accepted

Answered
Index in position 2 exceeds array bounds (must not exceed 1).?
I am not certain what ‘t’ is. However it appears to be a column vector, so the second index is not appropriate for it. t =...

4 years ago | 0

Answered
How to change the scale values of Y axis in Matlab?
Perhaps — ylim([min(ylim) 10]) That keeps the current minimum and set the maximum at 10. .

4 years ago | 1

Answered
How to plot two exponential functions on Matlab?
Another approach — x = linspace(0, 10); f = @(x) exp(-(((x-2)/3).^2)/2); g = @(x) 1-exp(-(((x-2)/3).^2)); figure plot(x,...

4 years ago | 1

| accepted

Answered
I am trying to translate a find_peaks function call in python to matlab and they use a max threshold
There is no 'MaxPeakHeight' so impose the maximum condition after the findpeaks call to limit the maximum peak values considered...

4 years ago | 0

| accepted

Answered
the meaning of a sentence in command window
The message means that the genetic algorithm converged successfully. It has reached what it considers to be the global minimu...

4 years ago | 2

| accepted

Answered
LaPlace Transform with initial conditions
The procedure is not exactly straightforward, so I will demonstrate a working approach — syms s t y(t) Y(s) D1y = diff(y); ...

4 years ago | 2

| accepted

Answered
How to connect points in the scatter3 plot?
To connect only the corresponding points (without connecting any others) requires a loop — LD1 = load('V_1.mat'); V_1 = LD1.V...

4 years ago | 0

| accepted

Answered
Calculate time period of a graph signal
Use findpeaks to get the peak indices and then use the associated time vector to calculate the period. Use the envelope functio...

4 years ago | 1

| accepted

Answered
convert a time series into a real time animated plot
Try something like this — LD = load('timeseries.mat'); time2 = LD.time2; Time = time2.Time; Data = time2.Data; DataRange =...

4 years ago | 0

| accepted

Answered
'dlmread' function reads the variables as a*10^-3.
Most likely, it is assigning a common multiple to the matrix being read. format long v = logspace(-3, 3, 9)' Check to see...

4 years ago | 0

Answered
how to select an interval of certain hours each day within a larger timetable using timerange
The timerange function operates on timetable arrays, so to use it, the data must be in a timetable and the times must be durati...

4 years ago | 0

| accepted

Load more