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

más de 7 años hace | 20

Resuelto


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

más de 7 años hace

Resuelto


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

más de 7 años hace

Resuelto


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

más de 7 años hace

Resuelto


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

más de 7 años hace

Resuelto


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

más de 7 años hace

Resuelto


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

más de 7 años hace

Resuelto


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

más de 7 años hace

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

más de 7 años hace | 0

Resuelto


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

más de 7 años hace

Resuelto


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

más de 7 años hace

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

más de 7 años hace | 0

Respondida
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)

más de 7 años hace | 0

Respondida
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)

más de 7 años hace | 0

Resuelto


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

más de 7 años hace

Resuelto


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

más de 7 años hace

Resuelto


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

más de 7 años hace

Resuelto


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

más de 7 años hace

Resuelto


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

más de 7 años hace

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

más de 7 años hace | 1

| aceptada

Resuelto


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

más de 7 años hace

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

más de 7 años hace | 0

Resuelto


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

más de 7 años hace

Resuelto


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

más de 7 años hace

Resuelto


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

más de 7 años hace

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

más de 7 años hace | 0

Respondida
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),...

más de 7 años hace | 1

| aceptada

Resuelto


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

más de 7 años hace

Resuelto


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

más de 7 años hace

Resuelto


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

más de 7 años hace

Cargar más