문제를 풀었습니다


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년 초과 전

문제를 풀었습니다


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년 초과 전

문제를 풀었습니다


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

13년 초과 전

문제를 풀었습니다


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년 초과 전

문제를 풀었습니다


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년 초과 전

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

13년 초과 전 | 0

문제를 풀었습니다


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년 초과 전

문제를 풀었습니다


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년 초과 전

문제를 풀었습니다


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년 초과 전

문제를 풀었습니다


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년 초과 전

문제를 풀었습니다


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년 초과 전

문제를 풀었습니다


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년 초과 전

문제를 풀었습니다


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년 초과 전

문제를 풀었습니다


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년 초과 전

문제를 풀었습니다


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년 초과 전

문제를 풀었습니다


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년 초과 전

문제를 풀었습니다


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

13년 초과 전

답변 있음
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년 초과 전 | 3

질문


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년 초과 전 | 답변 수: 1 | 1

1

답변

답변 있음
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년 초과 전 | 3

답변 있음
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년 초과 전 | 0

| 수락됨

답변 있음
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년 초과 전 | 0

| 수락됨

답변 있음
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년 초과 전 | 0

| 수락됨

답변 있음
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년 초과 전 | 0

답변 있음
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년 초과 전 | 1

답변 있음
"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년 초과 전 | 1

답변 있음
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년 초과 전 | 0

| 수락됨

답변 있음
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년 초과 전 | 2

| 수락됨

문제를 풀었습니다


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년 초과 전

답변 있음
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년 초과 전 | 0

| 수락됨

더 보기