Solved


Remove all the words that end with "ain"
Given the string s1, return the string s2 with the target characters removed. For example, given s1 = 'the main event' your ...

6 years ago

Solved


Return the largest number that is adjacent to a zero
This example comes from Steve Eddins' blog: <http://blogs.mathworks.com/steve/2009/05/27/learning-lessons-from-a-one-liner/ Lear...

6 years ago

Answered
how to sum data with condition
This is silly. But not difficult to implement. x = [1 100; 1 101 ; 1 102; 2 109 ; 2 116 ; 2 118 ; 2 120 ; 3 103; 3 106]; y = x...

6 years ago | 0

Solved


Find all elements less than 0 or greater than 10 and replace them with NaN
Given an input vector x, find all elements of x less than 0 or greater than 10 and replace them with NaN. Example: Input ...

6 years ago

Solved


Swap the first and last columns
Flip the outermost columns of matrix A, so that the first column becomes the last and the last column becomes the first. All oth...

6 years ago

Solved


Summing digits
Given n, find the sum of the digits that make up 2^n. Example: Input n = 7 Output b = 11 since 2^7 = 128, and 1 + ...

6 years ago

Solved


Remove any row in which a NaN appears
Given the matrix A, return B in which all the rows that have one or more <http://www.mathworks.com/help/techdoc/ref/nan.html NaN...

6 years ago

Solved


Return the 3n+1 sequence for n
A Collatz sequence is the sequence where, for a given number n, the next number in the sequence is either n/2 if the number is e...

6 years ago

Solved


Alphabetize by last name
Given a list of names in a cell array, sort the list by the last name. So if list = {'Barney Google','Snuffy Smith','Dagwood ...

6 years ago

Answered
How do I break the line for every 50th row in a matrix
Fairly simple. Just need to reshape the variables. Here is an example: d = 10; x = repmat(1:d,1,d)'; y = [sin(x)]; t = 1:len...

6 years ago | 0

Answered
Index 2D matrix along line rotated about the matrix midpoint
360/(N-1) doesn't make sense. What if N = 8? I think you just mean 180. But it's irrelevant. It would not be efficient to recrea...

6 years ago | 0

Answered
Why can't I solve this, it's simple. (Incorrect dimensions.... use .^) (I did then it says Invalid Operator.......)
This works fine: z = ((x+1).^y)-(x.^y); You should read a bit on the difference between array and matrix operations. https://...

6 years ago | 0

| accepted

Answered
incorrect result of fft phase calculation
There are two issues at play. The first is a trade-off between temporal resolution and spectral resolution. Your sampling freque...

6 years ago | 0

Answered
How to correct error in port width or dimension in simulink?
Reshape the signal going into 'ref' with a Reshape block, and select column vector as the output dimensionality.

6 years ago | 0

Answered
Function for even or odd numbers
function y = iseven(v) y = all(~mod(v,2)); end

6 years ago | 0

Answered
List comprehension-like function in assigning values in nested structures
You'll find the answer in this article on comma-separated lists, specifically with the _deal()_ function. <https://www.mathwork...

6 years ago | 1

Answered
How to stop for-loop outside of the loop?
Sounds like you want a GUI of a stop watch. https://www.mathworks.com/matlabcentral/fileexchange/12628-stopwatch

6 years ago | 0

| accepted

Answered
Multiple Summation of Series using For Loops
Very close. You need to reset the value of s for each y. I also cleaned it up a bit. This now produces the specified figure. c...

6 years ago | 0

| accepted

Answered
how i implement this equation.
Why do you want a loop to do this simple equation anyways? Ok here you go... clearvars; Ne = 9; Ni = 100; Eci = rand(Ni,Ne);...

6 years ago | 0

| accepted

Answered
Error using odearguments (line 113) Inputs must be floats, namely single or double.
Your function dynamics takes as inputs x and y, but instead uses t and y. So fix that. You are also passing in a symbolic value...

6 years ago | 0

Answered
Find the two nearest points from an array given a value
[~,k] = mink(abs(A-0.1400),2);

6 years ago | 4

| accepted

Answered
How to filter data using rmoutliers?
If you have a hard threshold you want to use, then rmoutliers is not the function you want. Just use a simple logical index to g...

6 years ago | 1

Answered
Calculate the FFT of an ECG signal
I haven't ran your code but the plot looks pretty normal. The peak you see around 0 Hz is a DC component added to your signal. Y...

6 years ago | 1

| accepted

Answered
How vectorize this operation
If you have the signal toolbox, you can use the buffer() command to an array of the x values that you require, then do the matri...

6 years ago | 0

Answered
Finding change in a large dataset
I agree with what Adam says in that there are certainly more efficient ways to solve this problem. That being said, I didn't hav...

6 years ago | 0

Answered
How do I make gaps in missing data plot lines?
help plot You are the one telling Matlab to plot a line between your data points. Try plot(x,y,'c.')

6 years ago | 0

Answered
using relational operators on array and element
if y>=var1 & y<=var2; var1 = 4 -1 -6 -11 -16 var2 = 6 1 -4 -9 -14 Let's say y = 5, so the condition abo...

6 years ago | 1

| accepted

Answered
Is there a way to avoid repeating time-consuming calculations from odefun in the events function?
You might find this comment by Walter Roberson useful, where he talks about using memoize().

6 years ago | 0

Answered
peak to peak amplitude comparison
You can't find the peak of a single data point. It is telling you to provide more data points in order for the function to work....

6 years ago | 0

| accepted

Load more