Solved

Number of toolboxes?

Return a number equal to the number of toolboxes available to the Cody solvers.

plus de 6 ans ago

Solved

Given a 4x4 matrix, swap the two middle columns

If a = [1 2 3 4; 1 2 3 4; 1 2 3 4; 1 2 3 4]; then the result is ans = 1 3 2 4 1 3 2...

plus de 6 ans ago

Solved

Related Vectors

I have two vectors A & B. If the values in vector A is zero then the corresponding value in vector B should be zero. Example:...

plus de 6 ans ago

Solved

Doubling elements in a vector

Given the vector A, return B in which all numbers in A are doubling. So for: A = [ 1 5 8 ] then B = [ 1 1 5 ...

plus de 6 ans ago

Solved

Simple equation: Annual salary

Given an hourly wage, compute an annual salary by multiplying the wage times 40 and times 50, because salary = wage x 40 hours/w...

plus de 6 ans ago

Solved

sum of first 'n' terms

Given n=10, find the sum of first 'n' terms Example: If n=10, then x=1,2,3,4,5,6,7,8,9,10. The sum of these n=10 terms is 55...

plus de 6 ans ago

Solved

Maximum value in a matrix

Find the maximum value in the given matrix. For example, if A = [1 2 3; 4 7 8; 0 9 1]; then the answer is 9.

plus de 6 ans ago

Solved

Fahrenheit to Celsius using multiple statements

Given a Fahrenheit value F, convert to a Celsius value C. While the equation is C = 5/9 * (F - 32), as an exercise use two state...

plus de 6 ans ago

Solved

Tiling a matrix

Given a matrix and a number of columns, replicate matrix in a single row

plus de 6 ans ago

Solved

Penny flipping - calculate winning probability (easy)

Two players are playing a fair penny flipping game. For each flip, the winner adds one penny from the loser's collection to his/...

plus de 6 ans ago

Solved

Duplicate a character

Duplicate a character 'n' times. Example 1: str='a' n=5 output='aaaaa' Example 2: str='*' n=3 output='***'

plus de 6 ans ago

Solved

Transpose

Write a MATLAB script in order to convert a random length row vector (v) into a column vector.

plus de 6 ans ago

Solved

Mode

Find the mode of the vector Assumption: no vector is bimodal Example 1: input=[1 2 3 4 4]; output=4 Example 2: input=[7...

plus de 6 ans ago

Solved

Circle area using pi

Given a circle's radius, compute the circle's area. Use the built-in mathematical constant pi.

plus de 6 ans ago

Solved

Do you like your boss?

Do you like your boss? Answer can be any string! For example: Boss = 'Do you like your boss?'; Output = 'yes' or ...

plus de 6 ans 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 ...

plus de 6 ans ago

Solved

vectorization in N

For a given integer n (n>1), compute the sum f (i) (1 <= i <= n) where f (i) = 1 if n is odd and 2 otherwise.

plus de 6 ans ago

Solved

Cannon Ball

Given g (acceleration due to gravity) and desired altitude x, find the minimum ground velocity of a cannon ball to reach x.

plus de 6 ans ago

Solved

Reverse the elements of an array

Reverse the order of elements in an array: eg: input X = [ 1 2 3 ; 4 5 6 ; 7 8 9 ] o...

plus de 6 ans ago

Solved

Getting the row and column location from a matrix

This is a basic MATLAB operation. It is for instructional purposes. --- You may already know how to get <http://www.mathwo...

plus de 6 ans ago

Solved

Back to basics 19 - character types

Covering some basic topics I haven't seen elsewhere on Cody. Return the number of punctuation characters in the input variabl...

plus de 6 ans ago

Solved

Back to basics 16 - byte order

Covering some basic topics I haven't seen elsewhere on Cody. Switch the byte order of the input (i.e. if little-endian -> big...

plus de 6 ans ago

Solved

Number of Circles in a Number

Given a number, return the number of closed 'circles' in the base 10 numerical representation. Note: the number 4 has no circ...

plus de 6 ans ago

Solved

sum of non-primes

The sum of the non-primes below 10 is 1+4+6+8+9+10=38 Find the sum of all the non-primes below the input, N.

plus de 6 ans ago

Solved

Triangle Numbers Below N

This is an offshoot of <http://www.mathworks.com/matlabcentral/cody/problems/5-triangle-numbers Cody Problem 5: Triangle Numbers...

plus de 6 ans ago

Solved

The Answer to Life, the Universe, and Everything

A variation of a previous Hitchhiker's Guide to the Galaxy problem. *Inputs:* Life, the Universe, and Everything *Output:*...

plus de 6 ans ago

Solved

Encode Roman Numerals

Create a function taking a non-negative integer as its parameter and returning a string containing the Roman Numeral representat...

plus de 6 ans ago