Gelöst


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

mehr als 13 Jahre vor

Gelöst


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

mehr als 13 Jahre vor

Gelöst


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

mehr als 13 Jahre vor

Gelöst


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

mehr als 13 Jahre vor

Gelöst


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

mehr als 13 Jahre vor

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

mehr als 13 Jahre vor | 0

Gelöst


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

mehr als 13 Jahre vor

Gelöst


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

mehr als 13 Jahre vor

Gelöst


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

mehr als 13 Jahre vor

Gelöst


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

mehr als 13 Jahre vor

Gelöst


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

mehr als 13 Jahre vor

Gelöst


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

mehr als 13 Jahre vor

Gelöst


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

mehr als 13 Jahre vor

Gelöst


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

mehr als 13 Jahre vor

Gelöst


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

mehr als 13 Jahre vor

Gelöst


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

mehr als 13 Jahre vor

Gelöst


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

mehr als 13 Jahre vor

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

mehr als 13 Jahre vor | 3

Frage


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

mehr als 13 Jahre vor | 1 Antwort | 1

1

Antwort

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

mehr als 13 Jahre vor | 3

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

mehr als 13 Jahre vor | 0

| akzeptiert

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

mehr als 13 Jahre vor | 0

| akzeptiert

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

mehr als 13 Jahre vor | 0

| akzeptiert

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

mehr als 13 Jahre vor | 0

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

mehr als 13 Jahre vor | 1

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

mehr als 13 Jahre vor | 1

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

mehr als 13 Jahre vor | 0

| akzeptiert

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

mehr als 13 Jahre vor | 2

| akzeptiert

Gelöst


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

mehr als 13 Jahre vor

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

mehr als 13 Jahre vor | 0

| akzeptiert

Mehr laden