Answered
How to use global variables inside a function?
First you need to define a variable say x as global global x x=5 Then in the function definition which is using the glo...

7 years ago | 20

Solved


Return elements unique to either input
Given two numeric inputs a and b, return a row vector that contains the numbers found in only a or only b, but not both. For ex...

7 years ago

Solved


Spot the outlier
All points except for one lie on a line. Which one is the outlier? Example: You are given a list of x-y pairs in a column ...

7 years ago

Solved


Return unique values without sorting
If the input vector A is [42 1 1], the output value B must be the unique values [42 1] The *values of B are in the s...

7 years ago

Solved


Find the largest value in the 3D matrix
Given a 3D matrix A, find the largest value. Example >> A = 1:9; >> A = reshape(A,[3 1 3]); >> islargest(A) a...

7 years ago

Solved


Specific Element Count
Given a vector _v_ and a element _e_, return the number of occurrences of _e_ in _v_. Note: NaNs are equal and there may be n...

7 years ago

Solved


Check if number exists in vector
Return 1 if number _a_ exists in vector _b_ otherwise return 0. a = 3; b = [1,2,4]; Returns 0. a = 3; b = [1,...

7 years ago

Solved


How many trades represent all the profit?
Given a list of results from trades made: [1 3 -4 2 -1 2 3] We can add them up to see this series of trades made a profit ...

7 years ago

Answered
Not enough input arguments
The code you have written is correct all that you need to do is to define the variable P after you have defined the value of A,B...

7 years ago | 0

Solved


Generate N equally spaced intervals between -L and L
Given N and L, return a list of numbers (in ascending order) that divides the interval [-L L] into N equal-length segments. F...

7 years ago

Solved


Find a subset that divides the vector into equal halves
Given a vector x, return the indices to elements that will sum to exactly half of the sum of all elements. Example: Inpu...

7 years ago

Answered
How to solve x^4-p*x+q.solve for x considering p and q as constants
Here is a better way to implement when you only have the equation given syms x %define the value of p and q y=x^4-p*x+q;...

7 years ago | 0

Answered
How to set domain for p(x)/q(x) functions?
You could just use this simple code instead syms x y=(x-1)/(x-2) ezplot(y)

7 years ago | 0

Answered
How to plot this equation in 3D?
You could use the following code syms x y z = ((1/x)^2 +y^2)^(1/2) ezsurf(z)

7 years ago | 0

Solved


Find the peak 3n+1 sequence value
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...

7 years ago

Solved


Return the Fibonacci Sequence
Write a code which returns the Fibonacci Sequence such that the largest value in the sequence is less than the input integer N. ...

7 years ago

Solved


Which values occur exactly three times?
Return a list of all values (sorted smallest to largest) that appear exactly three times in the input vector x. So if x = [1 2...

7 years ago

Solved


Interpolator
You have a two vectors, a and b. They are monotonic and the same length. Given a value, va, where va is between a(1) and a(end...

7 years ago

Solved


Maximum running product for a string of numbers
Given a string s representing a list of numbers, find the five consecutive numbers that multiply to form the largest number. Spe...

7 years ago

Answered
How to solve the following equations for vc(t)?
Try the following syms t; T=((vc-Vin)/Rc)*Tsw/2*1/(1.5*Il-0.5*Ipo); vc=(291*cos((6339586188837495*t)/137438953472)*exp(-...

7 years ago | 1

| accepted

Solved


How long is the longest prime diagonal?
Stanislaw Ulam once observed that if the counting numbers are <http://en.wikipedia.org/wiki/Ulam_spiral arranged in a spiral>, t...

7 years ago

Answered
Failure in initial objective function evaluation. FSOLVE cannot continue
I guess the mistake you are making is in using Tee = x(1); Cee = x(2); Rather it should be Tee = x0(1); Cee = x0(2)...

7 years ago | 0

Solved


Alternating sum
Given vector x, calculate the alternating sum y = x(1) - x(2) + x(3) - x(4) + ...

7 years ago

Solved


Replace NaNs with the number that appears to its left in the row.
Replace NaNs with the number that appears to its left in the row. If there are more than one consecutive NaNs, they should all ...

7 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...

7 years ago

Answered
Y(n)=5x(n-5)-3x(n 4)
I guess this is probably what you are looking for syms x n x(n)={1,2,3,4,5,6,7,6,5,4,3,2,1} x1(n)=5*x(n-5)-3*x(n+4) x...

7 years ago | 0

Answered
MATLAB program to find the roots of an equation
Instead of using fsolve try using vpasolve syms x c=0.2:0.1:2; y=cos(x)-c*x; for i=1:numel(y) sol(i)=vpasolve(y(i),...

7 years ago | 1

| accepted

Solved


Find the longest sequence of 1's in a binary sequence.
Given a string such as s = '011110010000000100010111' find the length of the longest string of consecutive 1's. In this examp...

7 years ago

Solved


Reverse Run-Length Encoder
Given a "counting sequence" vector x, construct the original sequence y. A counting sequence is formed by "counting" the entrie...

7 years ago

Solved


Trimming Spaces
Given a string, remove all leading and trailing spaces (where space is defined as ASCII 32). Input a = ' singular value deco...

7 years ago

Load more