Answered
Extracting data from Matlab .fig with 2 different y-axes?
Try something like this — x = linspace(0, 10); y1 = sin(2*pi*x/max(x)); y2 = exp(-0.2*x) .* cos(3*pi*x/max(x)); figure ...

4 years ago | 1

| accepted

Answered
Remove noise from time series data
The sgolayfilt function might be a better option. Try something like this — FrameLen = 201; DataFilt = sgolayfilt(data1, 3...

4 years ago | 0

| accepted

Answered
How could I program a "for loop" in Matlab to calculate the function's minimum value?
G = @(x,b) x.^2-b.*x+1; b=1:1:5; for k = 1:numel(b) xv(k) = fminsearch(@(x)G(x,b(k)), rand); end xv The first der...

4 years ago | 1

Answered
Can somebody help me how can I draw a hemisphere with flat top?
One approach — [X,Y,Z] = sphere(20); figure surf(X, Y, Z) axis('equal') grid on title('Original Sphere') Top = 0.85;...

4 years ago | 0

Answered
I have a matrix 592*2 from this I got a curve, now I need to calculate full width half maximum , how to do it?
There are several ways to do this, the easiest being the findpeaks function — B = readmatrix('B_mtx 2022 06 22.txt'); [pkd,lo...

4 years ago | 1

Answered
How to add a reference line power law of 1?
The power equation is , so choose independent variable , slope , and intercept and go from there — pwr_y = @(x,m,b) x.^m .* e...

4 years ago | 0

| accepted

Answered
How to do get my code to display an answer using f print f. I want to display the result using fprint f
Perhaps this — t_sec=[0 30 60 150 240]; Temp_C=[800 457 269 79 46]; time=0:1:250; pa=polyfit(t_sec,Temp_C,4); Pa=polyval(p...

4 years ago | 1

| accepted

Answered
Symbolic rewritten in matlab
An analytic solution is likely not possible, due to the nature of the expression. The only option is to solve it numerically ...

4 years ago | 0

| accepted

Answered
How to downsample a signal
Any resampling is not necessary. Just use the lowpass function to filter out everything above 8 kHz. (Use 'ImpulseResponse','i...

4 years ago | 1

| accepted

Answered
What is the x-axis in fft() command?
The x-axis will be frequency, that being defined as cycles/(time unit of the original independent varialble). If that is in sec...

4 years ago | 1

| accepted

Answered
Labelling colourbar using Latex
Try this — x = linspace(-3, 3, 50); [X,Y] = ndgrid(x); Z = exp(-(X.^2+Y.^2)); figure surf(X, Y, Z) grid on hcb = color...

4 years ago | 0

| accepted

Answered
Import data into datetime format
It would help to have the file and the MATLAB release you are using. It would be better to use readtable if you have it. Also,...

4 years ago | 0

Answered
How to calculate the FWHM from multiple spectra?
It might be easier if we had one or two typical .csv files to experiment with. The findpeaks WidthReference option is 'halfp...

4 years ago | 1

| accepted

Answered
Designing Filter for Accelerometer
The data are not regularly-sampled, so in order to do any meaningful signal processing on them, they need to be resampled to a c...

4 years ago | 0

Answered
Is it possible to find the index of an array based on the Xline?
I’n not exactly certain what you want, however this is relatively straightforward using the find function, and getting the inter...

4 years ago | 0

Answered
Error Index in position 2 exceeds array bounds
I don’t have ‘input_file’ however according to this lilne: data1 = textread(input_file,'%s'); the ‘data1’ variable is a colum...

4 years ago | 0

Answered
Why is my function not graphing in the plot?
Two problems: First, you need to do element-wise division: g = (sqrt(R.^2 * x.^2 * C.^2))./(sqrt(1 + (R.^2 * x.^2 * C.^2))) ...

4 years ago | 1

| accepted

Answered
Difficulties having log and linear y axes on same figure
The data are missing so I can’t run the posted code. Try something like this — x = linspace(0,100); y1 = 5.1+5*sin(2*pi*x*...

4 years ago | 2

| accepted

Answered
how to get my plot to only go to the value of 'n' I have set
The easiest way is to just use xlim — syms t; n = 0:20; N = 21; % piecewise of x1 and x2 for unit pulse x_n = [1, zeros(...

4 years ago | 0

Answered
How do I do the fourier transform of a data array?
Try this — % LD1 = load('ref_clean.mat'); % ref_clean = LD1.ref_clean; LD2 = load('data_clean.mat'); data_clean = LD2.data_...

4 years ago | 1

| accepted

Answered
Bug in islocalmin/islocalmax?
Those functions (and findpeaks) do not use anything that could be considered to be a ‘tolerance’. The ‘prominence’ of a peak (o...

4 years ago | 0

Answered
Area between the peak of the signal
I had to tweak the code slightly to get the result I needed for the ‘areav’ and ‘absareav’ calculations. Try this — % opts...

4 years ago | 0

| accepted

Answered
how to assemble a symbolic series?
Try something like this — b = randi([0 1], 1, 12) for k = 1:7 sb(k,:) = b(k:k+5); end sb bc = mat2cell(sb,ones(7,1),6...

4 years ago | 1

Answered
Undefined function periodgram for input arguments of type double?
It would be nice to know what ‘x’ is. If it is a table, the reference should be: x{:,1} (note the curly braces {}) instead...

4 years ago | 0

| accepted

Answered
How to solve an equation with one unknown and both sine and cosine
Try this — syms theta Eqn = 3.0179 == 6*cos(theta) - 2*sin(theta)*0.8660254038 theta = solve(Eqn, theta) thetav = vpa(thet...

4 years ago | 0

| accepted

Answered
Loading a .csv file that contains units
Try something like this — opts = detectImportOptions('CSV File Test 2022 06 17.txt'); opts = setvartype(opts, 'Var4','double'...

4 years ago | 0

Answered
Solve Equation and Plot it
The result ie not exactly the same as the plot in the original question, however it is close — alpha = 0.4207; skalar = 4.53...

4 years ago | 0

| accepted

Answered
How can I interpolate lines and colonnes
First, all four of those matrices would have to be entered separately. Second, use ndgrid to create the matrices from the nec...

4 years ago | 0

Answered
find first time 0 again after higher 0
One approach — M = [0 0 0 0.0619999999999550 0.108000000000004 0.129999999999995 0.156999999999982 0.176999999999964 0.1850000...

4 years ago | 0

| accepted

Answered
How to insert a zero column vector in a matrix according to a particular position?
Another approach — M = randn(4) % Original Matrix [rows,cols] = size(M); A = zero...

4 years ago | 0

Load more