how can we calculate interpolation between two double MATLAB arrays?
It depends on how you want to interpolate them. The‘safest’ way is likely to interpolate the longer vector to the length of the...

4 days ago | 0

| accepted

Changing Axes direction with positive z-axis downwards
If you only want to reverse the direcrtion of the z-axis, try this (after the surf call): set(gca, 'ZDir','reverse') The othe...

5 days ago | 0

Color background between two ylines patch (datetime)
The error is: Error using patch Non-numeric data is not supported in 'patch' So you can’t use it with datetime objects. I...

5 days ago | 0

| accepted

State Space modelling from an ODE
The easiest way is to let the Symbolic Math Toolbox do the heavy lifting: syms y(t) u(t) t Dy = diff(y); D2y = diff(y,2); ...

5 days ago | 2

| accepted

Splitting Cell Arrays by Delimiter
Try this: s = {'qwerty,uiop'; 'asdf,ghjkl,zxcvb'}; for k1 = 1:size(s,1) r(k1) = numel(strsplit(s{k1}, ',')); end Out = r ...

5 days ago | 0

Error bars in loglog plot
You appear to have ‘x_u’ and ‘x_l’ reversed. Try this: x_u = 3.2000e-12; x_m = 2.7111e-12; x_l = 2.2222e-12; y_u = 1.825...

5 days ago | 0

| accepted

lsqcurvefit error - Matrix dimensions must agree
I can’t run your code. However, some things are immediately obvious: (1) you are not integrating ‘myode’ inside ‘DiffEqSolver...

6 days ago | 1

convert two columns( one real number and the other is imaginary but without (i) symbol) in txt file to complex number and one column.
Try this: D = xlsread('New Microsoft Excel Worksheet.xlsx'); Cplx = complex(D(:,1),D(:,2));

6 days ago | 0

| accepted

How to find the numerical partial derivative of matrix
See if the gradient (link) function will do what you want. You will probably have to experiment with it, since I do not under...

6 days ago | 0

need to do a string interpolation
‘How can I write logic that would access a matrix but change the last character after each iteration.’ No need. I would conc...

6 days ago | 0

How can I bin Data
There are probalby several ways. One approach: x = randi(90, 90, 1); % Create Data y = r...

6 days ago | 0

numerical integration and solving for limit
You have told us nothing about ‘g(x)’. Assuming the integral of ‘g(x)’ is monotonically increasing at least until its integral ...

6 days ago | 1

| accepted

How can I draw the slope of the given values ​​on the chart?
I would use the gradient function rather than diff for this, since gradient produces a numerical derivative the same size as the...

6 days ago | 0

| accepted

how i can... meshgrid in matlab
Try this: xv = linspace(-1, 1, 20); [x1,x2] = meshgrid(xv); y = 35.5 + 10.5*x1 + 5.5*x2 + 8*x1.*x2; figure mesh(x1, x2, ...

7 days ago | 0

| accepted

Cylinder with top code
Those lines create flat upper and lower surfaces. The upper and lower surfaces otherwise would appear conical. The easiest w...

7 days ago | 0

Fit a curve so that a part of it is the same as another curve
I am not certain what you want to do. The two functions that are most likely to give you the desired resultl are linspace (link...

7 days ago | 0

| accepted

Switching scales on x axis
See if: set(gca, 'XDir','reverse') does what you want. That will reverse the x-axis direction, and the data associated with ...

7 days ago | 1

| accepted

Fsolve initial condition accuracy
Nonlinear solvers of all sorts (fsolve, lsqcurvefit, etc.) are very sensitive to the initial estimates, since they will search f...

7 days ago | 1

HOW to draw the type of graph in matlab
Try this approach, using ‘logical indexing’: k = 0.1; f = @(x) k*((0 < x) & (x < pi)); x = linspace(-pi/2, 3*pi/2); fig...

7 days ago | 1

How do I make surface plots with many NaN's in my matrix?
The fillmissing (link) function may be what you want. See specifically Matrix with Missing Endpoints (link).

7 days ago | 0

| accepted

Can the amplitude be plotted in dB?
Try this: semilogx(Fv, 20*log10(abs(FT_af(Iv,2))*2)), xlabel('Frequency, Hz'),ylabel('magnitude'); That will convert the ampl...

7 days ago | 1

| accepted

'Array indices should be positive' error
This is the reason: std=std(col); You ‘overshadowed’ the std function by naming your variable ‘std’. Do this and the probl...

7 days ago | 0

| accepted

How can I add a comment on a curve ?
You could use an annotation (link) object (that I find difficult to use because of the coordinate system they require), or you c...

8 days ago | 0

| accepted

how can i change x to (x+h)?
I am not certain what problem you are having. You have to define all the values you pass to your function as arguments before c...

8 days ago | 0

| accepted

function parameter includes h. I want plot title to include same h. how to do?
I have no idea what ‘h’ is, although I assume it’s a number. Try this: title(sprintf('Approximate and Exact Solution @h= %....

8 days ago | 0

How do i find the amplitude of a peak in my plot?
‘I want to find the peak with the most height(not the maximum y value, but the distance from the local minima just before the pe...

8 days ago | 0

fprintf in a for loop
I would do something like this: N = 12; k = 2; for i = 1:N-1 w(i) = k^i; w(i) end fid = fopen('Test2.txt', 'w');...

8 days ago | 0

| accepted

P values of fitting constants using FMINCON function
If you have fmincon, then you also have lsqcurvefit. Assuming you have constraints that lsqcurvefit can accommodate, use it to ...

8 days ago | 0