Answered
How do I pass a function a mathematical function of the for x.^2
If ‘Function’ is a string and contains only the variable ‘x’ — Function = "x^2" [y,x] = calculatethefunction(Function); ...

4 years ago | 0

| accepted

Answered
Wrong area filled with fitlm confidence interval
Use the patch function for best results — x_data = linspace(-7, 5, 25).'; y_data = randn(size(x_data)); mdl = fitlm(x_data...

4 years ago | 1

| accepted

Answered
Solving ODE in MATLAB with pre-defined steps
‘How can I specify that I do not want random values of t in the ODE? Here, I want t to range between 0 and 2.75 but I want a ste...

4 years ago | 1

Answered
How to Plot Numbers on top of Bar graphs?
Try this — components = {'First Design', 'Second Design', 'Third Design'}; x = [66.5 33.5; 68.7 31.3; 64.9 35.1]; figure ...

4 years ago | 0

| accepted

Answered
population variance (Equivalent of var.p command in excel in Matlab)
Try something like this — T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1165263/ffm.csv', 'Va...

4 years ago | 1

| accepted

Answered
How to plot the 3D exponential delay profile and Jake Doppler profile
It appears to be a surf function plot. It requires either three matrices, or two vectors and a matrix.

4 years ago | 0

Answered
How to flip the top x-axis so it matches the bottom plot?
I am not certain what you want. One option — ax_top.XAxis.TickLabels = 1./(ax_top.XAxis.TickValues); % <— ADDED...

4 years ago | 0

Answered
How to integrate cosine wave in MATLAB?
One way to ingegrate the ‘V1’ vector is to use cumtrapz — f=50; a=1000; dt=0:1e-6:40e-3; V1=a*cos(2*pi*f*dt); figure pl...

4 years ago | 0

| accepted

Answered
Bode different phase issue
In the freqs call, the phase is wrapped. Unwrap it and freqs matches bode — wp = 1; ws = 1.2; Rp = 0.2; Rs = 25; [n, Wn] ...

4 years ago | 0

Answered
How do I get just the x and y axis to show up?
Perhaps — axes See the documentation on axes for details. .

4 years ago | 0

Answered
Error between two non linear functions
The goodnessOfFit function is for System Identification Toolbox estimated systems. If you are estimating a nonlilnear model, ...

4 years ago | 0

| accepted

Answered
how find optimal threshold?
I am not certain what you are asking. The ‘threshold’ as illustrated would be the mean (or median) of the selected normal dis...

4 years ago | 0

| accepted

Answered
State-space system identification using known states, inputs, outputs
I generally use lsim rather than sim. Looking through the sim documentation for opt, the simOptions function has a way to speci...

4 years ago | 0

Answered
ss dont work properly
The ‘A’ and ‘B’ matrices contain symbolic variables. Use the subs function to assign numeric values to them, and then the dou...

4 years ago | 0

Answered
Add trend line to scatter plot with years in the X-axis
I am not certain what the data are. Assuming originally a datetime array and a double vector, try something lilke this — Da...

4 years ago | 0

| accepted

Answered
Calculate area of inside polygon using inpolygon
There are Mapping Toolbox functions areaint and similar functions to do this. Those might be more appropriate. Follow the link...

4 years ago | 1

| accepted

Answered
Methods for smoothing contour lines
I dislike going to external sites. Increasing ‘N’ would be the option I would use, initially experimenting with 250 and perha...

4 years ago | 1

| accepted

Answered
histogram of datetimes with customisable bin width
After doing a few conversions between datetime and duration to get all the arguments to be what the functions want — % input ...

4 years ago | 1

| accepted

Answered
surf plot of custom data
The data are all matrices. Unless I’m missing something, just plot them — LD1 = load(websave('X','https://www.mathworks.com...

4 years ago | 0

Answered
Carve a Pumpkin in MATLAB
I’m not certain what sort of ‘carved look’ you’re going for. With respect to drawing lines on the surface, one approach would b...

4 years ago | 0

Answered
How to add a single legent with multiple subplots with out overlapping on plots?
An alternative — Z = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1161928/Excel.xlsx', 'VariableN...

4 years ago | 0

| accepted

Answered
polyfit returning coefficients in order of ascending power (opposite of documentation)
I get different results — a = [0 1 2 3]; b = [0 1 2 3]; coeff = polyfit(a,b,1) eval = polyval(coeff,a) This is entirely co...

4 years ago | 1

| accepted

Answered
How to solve an ODE with three equation that are dependent on each other
Some of this is difficult to interpret. My best guess at a solution — v1=0.3; k2 = 0.3; %constant C = v1; % C = v1-dpdt;...

4 years ago | 0

Answered
Accumarray for two functions?
The accumarray approach is certainly possible — v = randn(250,1) Out = accumarray(ones(size(v)), v, [], @(x){{mean(x) std(x)}...

4 years ago | 2

Answered
how to plot different plots in the same MATLAB figure to compare time domain specification if the state space representation is given below
Perhaps — A = [-300 0 0 0 0 0; 0 -300 0 0 0 0; 0 0 0 0 1 0; 0 0 0 0 0 1; 10.7206 -9.5648 10.7206 -9.5648 0 0; -9.5648 10.7...

4 years ago | 1

| accepted

Answered
how to plot the gradient of a equation having specific region?
Perhaps this — syms x y f(x,y)=-5*x^3+4*y*x+6*y^3+1 Gf = gradient(f,x) figure fsurf(Gf, [-2 2 -2 2]) xlabel('X') ...

4 years ago | 0

Answered
Reading in a text file with numbers and strings in
It would help to haved the file. The readtable function would likely be best for this, since it will also import the variable...

4 years ago | 0

| accepted

Answered
Extract numbers from char type
Probably the easiest way — s = '4.64 km'; c = regexp(s, '\d*\.\d*|\d*', 'match') n = str2double(c) EDIT — (18 Oct 2022 at...

4 years ago | 2

| accepted

Answered
Shift lables for x and y axis on a graph
Perhaps xticklabels (although it takes a bit of experimenting to get it to work) — figure pcolor(rand(30)) xtl = xticklabels...

4 years ago | 0

| accepted

Answered
Selecting a line of data from a 3D surface
I would use griddedInterpolant for this — x = linspace(-1, 1, 25); y = linspace(0, 5, 35); [X,Y] = ndgrid(x, y); Z = exp(-...

4 years ago | 0

Load more