Answered
Reading time from the year numbers, day numer and hour number
I cannot find a way using the MATLAB date and time functions to convert these automatically. Try this — year_number=2019.24...

5 years ago | 0

| accepted

Answered
Plot Confidence Interval of 95%
The nlpredci funciton will work here, however in the presence of a constrained optimisation, no confidence limits may be reliabl...

5 years ago | 1

Answered
How can I compute the amplitude of a "experimental" sinusoïd ?
Two functions that could do what you want are the related islocalmax and islocalmin. Example — t = linspace(0, 1, 500); c ...

5 years ago | 0

| accepted

Answered
How do I write x(t/2) using handle operator @
Try something like this — x = @(t) (t/2); t = 42; y = x(t/2) See the documentation section on Anonymous Funcitons for detai...

5 years ago | 1

| accepted

Answered
Vectors must be the same length.
Use the gradient function instead of diff and define ‘t’ based on ‘y’ — % h=0.04; %step size % t=0.04:h:0.6; %time y=[0.1560...

5 years ago | 0

| accepted

Answered
Using is outlier with threshold
You have a typographical error. It should be 'percentiles', not 'percentile'. From the documentation: TF = isoutlier(A,'pe...

5 years ago | 0

| accepted

Answered
How to count the number of local extrema/peaks on 3D plot?
I cannot provide anything definitive without the data, however the islocalmax functionn (introduced in R2017b) could be the corr...

5 years ago | 0

Answered
How to find a y value given the x on a plot?
Use interpolation, specifically interp1 here. Without your data, an illustration would be something like this — x = linspac...

5 years ago | 0

| accepted

Answered
delelte certain string data from cell
The ismember function is usually reliable in these situations — C = {'abc';'def';'ghi';'ghi';'ghi';'jkl';'mno';'pqr'} TF = is...

5 years ago | 0

| accepted

Answered
How do I make bar graph spacing equal?
One approach — Y = [2021 2021 2021 2021 2021] ; M = [02 02 02 02 03] ; D = [09 17 22 24 02]; x = datetime(Y,M,D); y = [2...

5 years ago | 2

| accepted

Answered
Getting Infinte value for performing ifft
There is a infinite element in ‘s2’, and it was creating the NaN elements in the inverse result. Removing it and converting the...

5 years ago | 0

Answered
How to plot a graph like attached figure (in the form of steps).
Use the stairs function. Example — y = linspace(0,10*pi); x = sin(y)+1000; figure stairs(x, y) xline(1000, '--') xli...

5 years ago | 0

| accepted

Answered
How can I get Magnitude and Phase in this code?
That does not appear to be MATLAB syntax. Symbolically, this is straightforward — syms omega T real G(omega) = 1 - exp(-(1...

5 years ago | 0

Answered
Sum in function object
It is not possible to operate on funciton handles themselves. It is necessary to evaluate the functions — loss = @(W, x, y) l...

5 years ago | 1

| accepted

Answered
Running Prewritten MATLAB code
Open the Editor by typing: edit in the Command Window. Paste the code into an editor tab, save it by whatever name you want ...

5 years ago | 1

| accepted

Answered
Contour plot with 3 independent variables
It would help to have the matrix. Try something like this — figure contour(Vector_1, Vector_2, Matrix) .

5 years ago | 0

| accepted

Answered
string inputs and if else statement
‘... how i should write code after if statement so that if state =empty ...’ This line: if state1= isempty and state2 = ise...

5 years ago | 0

| accepted

Answered
displaying 2 graphs in singe run
‘... but evry time it replace the first graph ...’ It does not replace them. It creates a second figure and that figure is o...

5 years ago | 0

| accepted

Answered
Find two x values for one y value
C=1*10^(-4); L=3*10^(-1); R=100 N2=100; frez=1/(2*pi*sqrt(L*C)) %f value for Imax(theory of RLC c...

5 years ago | 1

| accepted

Answered
Finding position of main peak and difference between main peak and next peak in a 1d plot
x = linspace(0,10); y = 1.5*exp(-(x-2).^2) + 2*exp(-(x-7).^2*2.5) + exp(-(x-9).^2*5); [pks,locs] = findpeaks(y) [maxpk,...

5 years ago | 0

| accepted

Answered
string data in function
Perhaps something like this — data('Character Vector', pi, 42) data("String Variable", pi, pi) function data(a,b,c) displ...

5 years ago | 0

| accepted

Answered
Printing an error message if jacobi's method, does not converges.
One approach would be to set a limit on ‘itc’. If it fails to converge before ‘itc’ reaches some value (perhaps ‘iteration_limi...

5 years ago | 0

| accepted

Answered
Solve a system of two second-order differential equations using ode
Start by using the Symbolic Math Toolbox to set the equations up, then use odeToVectorField and matlabFunction to create an anon...

5 years ago | 0

| accepted

Answered
How to fit a log curve to a scatterplot?
If you have the Statistics and Machine Learning Toolbox, use the lsline funciton. Otherwise use polyfit and polyval. x =...

5 years ago | 0

Answered
The inbuilt code "bode " is not working
The same code works here, and runs without error, with either bode or bodeplot. I switched from bode to bodeplot because bode...

5 years ago | 1

| accepted

Answered
How to make a cross section of the 3D plot ?
Choose the appropriate ‘X’ and ‘Z’ (or ‘Y’ and ‘Z’) values from the matrix to get a cross-section. [X,Y,Z] = peaks(50); fi...

5 years ago | 2

| accepted

Answered
lsqcurvefit to estimate parameters in ODE15s
The problem is in the definition of ‘theta0’ and not including the initial conditions in ‘theta0’. Changing those produces — ...

5 years ago | 0

| accepted

Answered
Findpeaks from the excel data graph
To create a logical vector for ‘J’, just do: J = (x2>90 & x2<120); Then the reference to it works correctly. However there...

5 years ago | 0

| accepted

Answered
Filter data series on amplitude as a function of time
Try this — s = readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/632075/data.txt'); t = linspace(0,n...

5 years ago | 0

| accepted

Answered
How to solve equation by iteration
One problem is that ‘Psi’ is used before it is defined. Preallocating fixes that, however it may not solve the larger problems....

5 years ago | 0

| accepted

Load more