Answered
How would I find the median RR interval in an ECG signal?
Perhaps this — Fs = 500; t = linspace(0, 100, 100*Fs)/Fs; EKG = randn(size(t)); [pks, locs] = findpeaks(EKG, 'MinPeakProm...

3 years ago | 1

Answered
Why am I receiving three outputs for this lsim function?
You’re actually receiving four, one for each state. However if you create a system object out of the matrices first, you only...

3 years ago | 0

Answered
How can I get x-y values for a given z coordinate from a 3d surface plot?
You can use the find function to get the index coordinates of the point (it may require creating a tolerance, since the value yo...

3 years ago | 0

Answered
Interpolation from a table
The interp2 function is one option — eb = [0 0.25]; yb = [0.5; 0.75]; K0 = [1.0009 1.3767; 0.9948 1.5583]; Check = [N...

3 years ago | 0

Answered
indexing through array in for loop
What function are you using to estimate the statistic? I don’t see any built-in MATLAB functions for it, although I may be loo...

3 years ago | 0

Answered
Can i pass an array of n strings to a function that takes n strings as input?
The plot calls should probably be referencing ‘i’ instead of ‘n’ and if you have R2016b or later, you can use string arrays — ...

4 years ago | 0

Answered
Error using patch not enough input arguments
The 'FaceColor' name-value pair is not necessary in patch calls. Just use the designated colour or RGB triplet as the third arg...

4 years ago | 0

| accepted

Answered
Differential equation unable to find a symbolic solution
The equation is nonlinear in , and dsolve will not solve nonlinear differential equations. Integrating it numerically gives —...

4 years ago | 0

| accepted

Answered
How to perform summation of the given equation?
The ‘dz’ may mean the function is an integrand — syms z H = sym(10); k(z)=(15/2)*(H-z)*(sin(30)); K = int(k, z, 0, 10) K ...

4 years ago | 0

| accepted

Answered
How can I produce a plot like the one in the picture using quadratic equation in MATLAB?
I have no idea what the picture demonstrates. Perhaps something like this — a = randn b = randn c = randn r = roots([a b...

4 years ago | 1

Answered
Envelope function of a signal
Use the envelope function. t = linspace(0, 1, 1E+3); s = sin(2*pi*t*5) .* sin(2*pi*t*100); [senvu,senvl] = envelope(s, 10...

4 years ago | 0

| accepted

Answered
Variable "Flag" is not fully defined in some execution paths. Why?
Because there are conditional statements in the code, and not all of them set the ‘Flag’ variable. One way to avoid that is t...

4 years ago | 1

Answered
Convert audioread file to obtain spl
Use the Audio Toolbox function splMeter.

4 years ago | 0

| accepted

Answered
Adding Non-Plotted Items to Figure Legend
Perhaps something like this — x = 1:20; y(1,:) = 0.5+randn(size(x))*0.1; y(2,:) = 0.5+randn(size(x))*0.1; figure plot(x,...

4 years ago | 0

Answered
Hi. I am having issues with having my matlab get past the ifourier part of my code. It just continually runs and is stuck at that part. The bold is where my computer is stuck.
It seems to work here — m = 10; % kg k = 15; % N/m b = 8; syms x(t) Dx = diff(x,t); h_eqn = m*diff(x,t,2) + b*dif...

4 years ago | 0

Answered
function answer is displayed twice
‘How do I get rid of the ans= part being displayed as well?’ Perhaps: calcMax; (added semicolon) .

4 years ago | 0

Answered
title plot can't be shown + grid
The title and grid functions do not apply until the axes are created. Also, there are two ‘subplot(2,3,1)’ creations, the secon...

4 years ago | 0

| accepted

Answered
How to integrate using the for loop?
No loop necessary — LD = load(websave('V1','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1172553/V1.mat')); ...

4 years ago | 0

Answered
Errors in loops in Matlab
Perhaps you intended: k(t+1)=alpha*k(t)^(alpha-1)+(1-delta)*k(t)-c1(t); ↑ instea...

4 years ago | 0

Answered
find Maximum values in intervals of time(each 2000 values)
It would help to have the data. Try something like this — u = randn(1, 24001); t = 1:numel(u); r = 2000; U = zeros(r,c...

4 years ago | 0

| accepted

Answered
Predict power consumption using linear regression
There are 89 days in the data, so the data ‘wrap’ to 24 hours. T1 = readtable('https://www.mathworks.com/matlabcentral/answer...

4 years ago | 0

| accepted

Answered
Using regular expressions to filter files
There appears to be only one comma (,) in each line, so perhaps the extractAfter function (introduced in R2016b) will work. C...

4 years ago | 0

| accepted

Answered
How do I change the direction of the numbers on my axis.
I’m not certain what you want, however something like this may do what you want — x = linspace(-1, 1, 10); y = (x+1).^2; f...

4 years ago | 2

Answered
readmatrix command is not working.
The readtable function was introduced in R2013b, and the readmatrix funciton in R2019a. If you do not have readmatrix, see if...

4 years ago | 1

| accepted

Answered
How to derive and plot derive for a set of data with non linear x axis?
I have no idea what the data are. Calculationg the numerical derivative is straightforward with the gradient function — x =...

4 years ago | 0

Answered
Extracting Data from a .fig File
This should do what you want — F = openfig(websave('Group10%20heating','https://www.mathworks.com/matlabcentral/answers/upload...

4 years ago | 0

Answered
How to convert rows to logical
Why not just: A = 1:10; %fitering happens r = [2 7 8]; %the rows to keep Afiltered = zeros(size(A)); Afiltered(r) = A(r) ...

4 years ago | 1

| accepted

Answered
How to plot lines with unordered data points?
One approach — LD = load(websave('xydata','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1171138/xydata.mat')...

4 years ago | 0

| accepted

Answered
How can I plot this function?
This requires a surface plot with separate plots for the real and imaginary components — lambdaI = randn; ...

4 years ago | 0

Answered
Find peaks in a for loop?
The maxk and mink functions (introduced in R2017b) would make this a bit more efficient. Lacking them, use sort. Try this — ...

4 years ago | 0

| accepted

Load more