Answered
converting sym function to string MATLAB
Try this — syms x y eqn = x^2+2*x*y+3*y^2; partial_eqn = diff(eqn, x); fprintf("The partial derivative of %s w.r.t. x is...

5 years ago | 3

| accepted

Answered
Use results in the definition of my functions
Try this instead — function pv=p(X,x) pv=X(1)*x.^2+X(2)*x+X(3); end Here, ‘X’ are the parameters and ‘x’ is the variabl...

5 years ago | 0

| accepted

Answered
Could someone please explain me this code?
That looks like something I wrote! It would be helpful to know the context (I don’t remember where I posted it), however it a...

5 years ago | 1

| accepted

Answered
Integrating a 2nd order ODE
This is a boundary value problem. Use bvp4c to solve it. syms y(x) x L Y q(x) = 2*cos(pi*x/L); Dy = diff(y); D2y = diff(...

5 years ago | 0

| accepted

Answered
How can I call half of text by using "textread" ? (1*4096 matrix to 1*2048 matrix)
I have never used textread, however that could be described in the format string, for example — formatStr = [repmat('%f',1,204...

5 years ago | 0

| accepted

Answered
my fminsearch function doesn't get the optimum values
The fminsearch function searches for a minimum. To get a maximum, negate the function — [x,fval] = fminsearch(@(x)-tut2(x),[1...

5 years ago | 1

| accepted

Answered
plotting a for loop returns Empty Graph
I’m not certain what you want, however it is necessary to subscript the varialbes to be plotted. This runs without error and ...

5 years ago | 0

Answered
Area between three curves
Try this — I created the comparisons as ‘>=’ so change those to simply ‘>’ ito make the comparisons strictly ‘greater than’. ...

5 years ago | 0

Answered
Hi, I want to know knee point of a curve including the process of by 2nd derivative. Can anyone help by creating the script.
Use the gradient function to calculate the numerical derivative — x = linspace(0, 10); y = exp(-0.1*x) .* sin(x); D1 = g...

5 years ago | 0

Answered
I have to use Fourier Transform without frequency range?
One approach — A = [1 0.43 0.95]; B = [0.97 0.43 0.97]; [h,t] = impz(B,A); figure subplot(2,1,1) plot(t, h) grid ...

5 years ago | 0

| accepted

Answered
Turn multiple columns into one column
The code is a bit difficult to follow. I’m guessing here that you want to save the ‘allfrequency’ vectors. allfrequency(s,:)...

5 years ago | 0

Answered
To find the average of values in matrix
Try something like this (assuming that they are stored as elements of a cell array similar to these) — C = {randn(131,160), ra...

5 years ago | 0

Answered
Index exceeds the number of array elements in ODE using anonymous function
There’s a typo: 1/L13*(x(24) - (x(30)/C15 + (x(25) - x(31))*R1) - x(25*RL13)); ...

5 years ago | 0

| accepted

Answered
Incorrect datatype when using 'retime' function
The retime function works only with timetable arrays, to the best of my knowledge. See if using the table2timetable funciton fi...

5 years ago | 0

Answered
Bug in equality checks? 28.15e-3 == 28.15/1000 false
Wellcome to the world of floating-point approximation error! See Why is 0.3 - 0.2 - 0.1 (or similar) not equal to zero? and...

5 years ago | 1

| accepted

Answered
how to write an Algebraic Equation in Matlab
I am not certain exactly what you want. See if this works — C = 31 Vinitial = 310 Vfinal = 320 Energy_stored_in_a_Capaci...

5 years ago | 0

| accepted

Answered
How to Calculate the 1% value of using gevfit
The gevinv funciton will likely do what you want, given the parameters. Copying from the image — X = gevinv([0.01 0.99], -0...

5 years ago | 0

Answered
I didn't know how to find r
A different approach — ac = 6*18*18 as = @(r) (4*pi*r.^2) r = fzero(@(r) ac - as(r), -1) Check_Equal_Areas = ac - as(r)...

5 years ago | 0

Answered
Plot how the input changes
Try something like this — b = @(m,x,y) y-m.*x; x = 1; m = linspace(0,10,11); y=2; figure plot(m, b(m,x,y)) grid xla...

5 years ago | 1

Answered
Function output is returning equation not value
If ‘rad’ is purely numeric (no symbolic variables), use the double function to onvert it to a double value. Also consider usi...

5 years ago | 1

Answered
how to solve error using integral
Not certain what the desired result is, however everything here are arrays or vectors, so use trapz instead, since there are no ...

5 years ago | 0

Answered
Array of the number of days in the month of February this year
Numer of days: eomday Array of days: calendar .

5 years ago | 1

Answered
The longest consecutive values in a vector and the position at which it starts and ends
One approach — A = [35, 25, 40, 20, 20, 30, 30, 30, 30, 30, 9, 20, 30, 10, 30]; [Au,~,ix] = unique(A, 'stable'); Tally = a...

5 years ago | 0

| accepted

Answered
How do I generate a pdf from some known percentile values
A slightly different approach — prctiles = [5 10 30 33 50 67 70 90 95]; SLR = [3.2760 3.5265 ...

5 years ago | 1

| accepted

Answered
Data Recovery for the Original Image
See for example: How do I extract data from MATLAB figures? Use the saveas function to save the resulting figure as a .png imag...

5 years ago | 0

Answered
how to change the front size and the inclination in a bar graph
‘2- how can I get the name to be written normally( those low characters should be on the same level as others)’ ‘Escape’ th...

5 years ago | 0

Answered
Convolution of two Gaussian functions without conv
Just choose any arbitrary vector for ‘z’ that is long enough to completely support the signals to be convolved. For a Gaussian,...

5 years ago | 1

| accepted

Answered
Finding top and bottom 10% of data
If the Statistics and Machine Learning Toolbox is available, use the prctile function — x = randn(1,20) ...

5 years ago | 0

Answered
Hello Everyone, I need to pass a low pass filter in this plot and I can't find the best way to do that. Someone can help me? Thanks.
Use the freqz function (or freqs linked to in that documentation page, if it is a continuous-time filter) — [b,a] = butter(8...

5 years ago | 0

| accepted

Answered
Why do I get "Array indices must be positive integers or logical values"?
MATLAB does not recognise implicit multiplication, so the missing multiplication operator vt=vf(1-exp(-t/tao)); ↑ ← HERE ...

5 years ago | 0

Load more