A résolu


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

plus de 14 ans il y a

A résolu


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

plus de 14 ans il y a

A résolu


Triangle Numbers
Triangle numbers are the sums of successive integers. So 6 is a triangle number because 6 = 1 + 2 + 3 which can be displa...

plus de 14 ans il y a

A résolu


Find all elements less than 0 or greater than 10 and replace them with NaN
Given an input vector x, find all elements of x less than 0 or greater than 10 and replace them with NaN. Example: Input ...

plus de 14 ans il y a

A résolu


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

plus de 14 ans il y a

A résolu


Select every other element of a vector
Write a function which returns every other element of the vector passed in. That is, it returns the all odd-numbered elements, s...

plus de 14 ans il y a

A résolu


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

plus de 14 ans il y a

A résolu


Find the sum of all the numbers of the input vector
Find the sum of all the numbers of the input vector x. Examples: Input x = [1 2 3 5] Output y is 11 Input x ...

plus de 14 ans il y a

A résolu


Make the vector [1 2 3 4 5 6 7 8 9 10]
In MATLAB, you create a vector by enclosing the elements in square brackets like so: x = [1 2 3 4] Commas are optional, s...

plus de 14 ans il y a

A résolu


Determine if input is odd
Given the input n, return true if n is odd or false if n is even.

plus de 14 ans il y a

Réponse apportée
Angle Comparison
If I understand this setup correctly, then the following is true. Take a line segment (I take this to be what you mean by side)...

plus de 14 ans il y a | 0

Réponse apportée
Cumsum Function Reproduction
[DELETED]

plus de 14 ans il y a | 0

Réponse apportée
strings in a loop
Sven, In most Matlab functions that display text, you can pass a cell array of strings to accomplish new lines. The example ...

plus de 14 ans il y a | 0

| A accepté

Réponse apportée
conversion
Baba, This will do what you described. structVar(1).name = 'First'; structVar(2).name = 'Second'; makeVarFun = @(s...

plus de 14 ans il y a | 0

Réponse apportée
Non-linear Optimization for adjusting one trajectory to another (one matrix transformed to match other).
Try an anonymous function handle instead of an inline function, like this. difference_fun = @(x) norm( T1 - x(4)*T2 * ... ...

plus de 14 ans il y a | 0

| A accepté

Réponse apportée
Switch Case where case is a word_anynumber
If all of your cases are similar to what you describe, then you can use strtok like this. a = 'word_4'; b = 'word_27'; ...

plus de 14 ans il y a | 0

Réponse apportée
FASTA AND BLAST
The following commands and output says there are not such functions. >> help fasta fasta not found. Use the Help br...

plus de 14 ans il y a | 0

Réponse apportée
Reflection of a surface across an axis
Braden, This example should help you see what to do. hand = surf(peaks); set(hand, 'XData', -1*get(hand,'XData'));

plus de 14 ans il y a | 0

| A accepté

Réponse apportée
Gaussian Propability Area at different alpha
I believe this will accomplish your purpose. Let me know. LoS = .99; % Your level of significance lower = (1 - LoS) / ...

plus de 14 ans il y a | 0

Réponse apportée
Sphere into equal parts
Abhinendra, I believe what you are looking for can be accomplished with this item ( <http://www.mathworks.com/matlabcentral/fil...

plus de 14 ans il y a | 0

Question


speed of rand vs randi
I sometimes use "if rand < 0.5" or "if randi(2) == 1" to arbitrarily select one branch or another with equal probability. I ran...

plus de 14 ans il y a | 1 réponse | 0

1

réponse

Réponse apportée
multiplying adjacent values in matrix
See if this works for you. A = primes(100); B = A(1:end-1) .* A(2:end);

plus de 14 ans il y a | 0

| A accepté

Réponse apportée
Is there an elegant way to create dynamic array in MATLAB?
liangjian, You can preallocate based on the number of iterations. Try something like this. numIter = 100; array = ...

plus de 14 ans il y a | 1

Réponse apportée
randperm
If you want to randomly permute the rows, do something like the following. n = 5; A = reshape(1:2*n, n, 2) B = A(rand...

plus de 14 ans il y a | 0

Réponse apportée
Need help for cross checking of eigen Vector
This gives a possible set of unit eigenvectors. [V,D] = eig(A) If there is an eigenspace of more than one dimension, the vec...

plus de 14 ans il y a | 1

| A accepté

Réponse apportée
how to initialize an M×N array whose size is unknown in for-loop
A. Hill, You can probably get a good estimate of the number of elements by examining the file sizes. Suppose the files are i...

plus de 14 ans il y a | 0

Réponse apportée
Minimize function with respect to multiple variables
You can use the function fminsearch for this, which requires an initial guess. Here is how it might look for you. x = 1; ...

plus de 14 ans il y a | 5

| A accepté

Réponse apportée
How to put stacked plots in the same graph
Alan, To plot the data all in the same plot, do something like the following. x1 = 0:.01:1; y1 = x1.^2; x2 = .5:.1...

plus de 14 ans il y a | 1

| A accepté

Réponse apportée
Warning: Imaginary part is currently ignored.
This warning means that one of the inputs to atan2 is imaginary. The two places you use atan2 are extracted below. q2=atan...

plus de 14 ans il y a | 0

| A accepté

Réponse apportée
Re-arranging an exponential function of 2 parts
Simon, There is no logarithm rule that allows you to solve for x explicitly. However, from differentiating we can see that i...

plus de 14 ans il y a | 0

Charger plus