Solved


Flip the main diagonal of a matrix
Given a n x n matrix, M, flip its main diagonal. Example: >> M=magic(5); >> flipDiagonal(M) 9 24 1 ...

13 years ago

Solved


Sum of diagonal of a square matrix
If x = [1 2 4; 3 4 5; 5 6 7] then y should be the sum of the diagonals of the matrix y = 1 + 4 + 7 = 12

13 years ago

Solved


All capital?
Are all the letters in the input string capital letters? Examples: 'MNOP' -> 1 'MN0P' -> 0

13 years ago

Solved


Swap the input arguments
Write a two-input, two-output function that swaps its two input arguments. For example: [q,r] = swap(5,10) returns q = ...

13 years ago

Solved


Create times-tables
At one time or another, we all had to memorize boring times tables. 5 times 5 is 25. 5 times 6 is 30. 12 times 12 is way more th...

13 years ago

Answered
I need help with a loop.
You could start with something like: personCnt = 0 ; while true fprintf('\n--- Person %d\n', personCnt+1) ; ...

13 years ago | 0

Solved


Summing Digits within Text
Given a string with text and digits, add all the numbers together. Examples: Input str = '4 and 20 blackbirds baked in a...

13 years ago

Solved


How to find the position of an element in a vector without using the find function
Write a function posX=findPosition(x,y) where x is a vector and y is the number that you are searching for. Examples: fin...

13 years ago

Solved


Remove the vowels
Remove all the vowels in the given phrase. Example: Input s1 = 'Jack and Jill went up the hill' Output s2 is 'Jck nd Jll wn...

13 years ago

Solved


Back and Forth Rows
Given a number n, create an n-by-n matrix in which the integers from 1 to n^2 wind back and forth along the rows as shown in the...

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

13 years ago

Solved


Most nonzero elements in row
Given the matrix a, return the index r of the row with the most nonzero elements. Assume there will always be exactly one row th...

13 years ago

Solved


Finding Perfect Squares
Given a vector of numbers, return true if one of the numbers is a square of one of the other numbers. Otherwise return false. E...

13 years ago

Solved


Weighted average
Given two lists of numbers, determine the weighted average. Example [1 2 3] and [10 15 20] should result in 33.333...

13 years ago

Solved


Determine whether a vector is monotonically increasing
Return true if the elements of the input vector increase monotonically (i.e. each element is larger than the previous). Return f...

13 years ago

Solved


Column Removal
Remove the nth column from input matrix A and return the resulting matrix in output B. So if A = [1 2 3; 4 5 6]; and ...

13 years ago

Solved


Add two numbers
Given a and b, return the sum a+b in c.

13 years ago

Answered
Why are relational operators so slow in this case?
The first thing that comes to my mind is that you could store slices in 2D variables to eliminate repetitive similar block-index...

13 years ago | 3

Question


Building multi-scale rectangular grids based on raster zonal statistics.
Dear all, I am using some algorithm of my own for building multi-scale rectangular grids with a refinement depth based on zon...

13 years ago | 1 answer | 1

1

answer

Answered
Why does MATLAB confuse index variables in a for loop???
You are using the same index variable |i| in both nested loops. You should rename both differently (e.g. |ii| and |jj|) and then...

13 years ago | 3

Answered
How to NaN data in a time series if it changes quickly?
Or this (assuming that your data is stored in variable |data|): lid = diff(data) <= -5 ; data([lid, 0] | [0, lid]) = NaN ;...

13 years ago | 0

| accepted

Answered
How to insert data into matrix form?
Is it something like x = [k11, k12; k21, k22] ; that you want to do? If |knn| were row vectors and you wanted to build a ...

13 years ago | 0

| accepted

Answered
How to plot 3 different values in single plot in real time.
Using |hold on| allows you to plot consecutively on the same figure without erasing the previous content. E.g. figure(1) ; ...

13 years ago | 0

| accepted

Answered
How to indicate this data.?
Try with this: figure(1) ; clf ; hold on ; rotate3d on ; point = dlmread('N3d.txt'); plot3(point(:,1),point(:,2)...

13 years ago | 0

Answered
Checking if inputs of function are numeric
|L| *is* a "variable within the function". It is a local variable, created when the function is called, and its value is set to...

13 years ago | 1

Answered
"for" loop question
I can't figure out what you are trying to do, but here are some bits of code that may simplify the discussion.. Assume that w...

13 years ago | 1

Answered
How to make an anonymous function for variable amount of input data
It is difficult to implement conditional statements in anonymous functions (it requires a test function); why do you want to use...

13 years ago | 0

| accepted

Answered
The CLASS function must be called from a class constructor.
If you want to learn OOP in MATLAB, have a look at this document: <http://www.mathworks.com/help/pdf_doc/matlab/matlab_oop.pdf M...

13 years ago | 2

| accepted

Solved


Make a checkerboard matrix
Given an integer n, make an n-by-n matrix made up of alternating ones and zeros as shown below. The a(1,1) should be 1. Example...

13 years ago

Answered
How can I (quickly) buffer a river centerline with constant width to compute banks?
Your approach generates narrower streams than what you want, and will fail each time the angle is greater than pi/2, as at least...

13 years ago | 0

| accepted

Load more