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

mehr als 7 Jahre vor | 20

Gelöst


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

mehr als 7 Jahre vor

Gelöst


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

mehr als 7 Jahre vor

Gelöst


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

mehr als 7 Jahre vor

Gelöst


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

mehr als 7 Jahre vor

Gelöst


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

mehr als 7 Jahre vor

Gelöst


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

mehr als 7 Jahre vor

Gelöst


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

mehr als 7 Jahre vor

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

mehr als 7 Jahre vor | 0

Gelöst


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

mehr als 7 Jahre vor

Gelöst


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

mehr als 7 Jahre vor

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

mehr als 7 Jahre vor | 0

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

mehr als 7 Jahre vor | 0

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

mehr als 7 Jahre vor | 0

Gelöst


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

mehr als 7 Jahre vor

Gelöst


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

mehr als 7 Jahre vor

Gelöst


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

mehr als 7 Jahre vor

Gelöst


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

mehr als 7 Jahre vor

Gelöst


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

mehr als 7 Jahre vor

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

mehr als 7 Jahre vor | 1

| akzeptiert

Gelöst


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

mehr als 7 Jahre vor

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

mehr als 7 Jahre vor | 0

Gelöst


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

mehr als 7 Jahre vor

Gelöst


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

mehr als 7 Jahre vor

Gelöst


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

mehr als 7 Jahre vor

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

mehr als 7 Jahre vor | 0

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

mehr als 7 Jahre vor | 1

| akzeptiert

Gelöst


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

mehr als 7 Jahre vor

Gelöst


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

mehr als 7 Jahre vor

Gelöst


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

mehr als 7 Jahre vor

Mehr laden