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

Answered
Problem getting Matlab to plot data
Add: yAxisDataPwr = str2double(data{4:end,i}); to convert the character vectors to numerical values just before the plot call...

4 years ago | 1

| accepted

Answered
Change Width of line
The ‘I_BT’ value is missing. cycnr80 = interp1(Dk,(1:numel(Dk)),80) This should produce the cycle number where ‘Dk’ crosses ...

4 years ago | 0

Answered
Converting whole numbers to scientific notation
Another option — expstr = @(x) [x(:).*10.^ceil(-log10(abs(x(:)+(x==0)))) floor(log10(abs(x(:)+(x==0))))]; % Updated: 202...

4 years ago | 0

Answered
How to interpolate the local peak elevation to obtain the profile ?
One option is the envelope function. Choose the 'peak' option and an appropriate value for the window length.

4 years ago | 0

Answered
Intersection of two curves in matlab
The ‘I_BT’ variable is missing, so I cannot run the code. However getting the intersection of the exponential and the line is ...

4 years ago | 0

Answered
Interpolating each row of a matrix with NaN values
I am not certain that I understand the problem, however if the intent is to interpolate the NaN values, see if the fillmissing f...

4 years ago | 0

| accepted

Answered
Expected Shortfall for asset returns
If I understand correctly what you want to do, it would likely be easier to create ‘ind’ as a logical vector. There is also no ...

4 years ago | 0

| accepted

Answered
Make unit vectors at equal angles without for loop
Possibly — a = linspace(0, 2*pi, 7); r = 1; x = r*cos(a); y = r*sin(a); zv = zeros(size(a)); figure plot([zv; x], [zv;...

4 years ago | 0

Answered
How to draw the figure dot like this. ( I have a example figure.)
Try this — A = [30 45 60; 0.069491 0.135992 0.398871; 0.069491 0.135992 0.398871]+[0; 0; 0.3]; figure plot(A(1,:), A(2:3...

4 years ago | 0

| accepted

Answered
How can I make a 3D bar chart for a 1044X22 array which is colored with height?
I am not certain how clearly that sort of matrix can be defined Try this — Data = rand(1044,22); figure b = bar3(Data); ...

4 years ago | 0

| accepted

Load more