Answered
Computational neuroscience - I have a 116x116x226 I need to calculate the eigenvalues for this array can anyone help me?
A 3D array is not a matrix, and matrix multiplication is not defined for such arrays. Eigenvalues and eigenvectors are defined ...

1 year ago | 1

Answered
Duplicate a matrix using nested for loops
What's wrong with B = A; % ? However, if you absolutely must do it with nested for-loops then do: [m,n] = size(A);...

1 year ago | 0

| accepted

Answered
2-D Ray Tracing
Let P1=[x1,y1] and P2=[x2,y2] be the two endpoints of a line segment of the reflecting "wall", and let P3 = [x3,y3] be a point o...

1 year ago | 1

| accepted

Answered
A value belongs to an interval
To display the values you want write: A(4<A&A<5)

1 year ago | 0

Answered
Combine multiple if statements for something more compact
You can replace the part of the code after "%Speed Conditions" but before "% Power and performance" by these lines: t = Vm...

1 year ago | 1

Answered
bonsoire a tous ,commet je peut définir la taille d'une matrice ou d'un vecteur ? je veut par exemple une latrice de taille [m n]sachant que cette code ne me permet pas de faire ce que je veut
You can only do that if you assign values to every element of such a matrix. For example, you can set them all to zeros: M...

1 year ago | 0

| accepted

Answered
Line 11 Error: Subscript indices must either be real positive integers or logicals.
In the line k2 = y(n+h*k1)*(3-t(n+1)*y(n+h*k1)); the quantity n+h*k1 may not be a positive integer. If so, it is invali...

1 year ago | 0

Answered
checking that a user input is an integer
Test whether this is true. If so, 'prompt' is an integer, otherwise it is not. prompt==round(prompt)

1 year ago | 1

Answered
what is wrong with my newton code? file attached
There are three things that need correcting 1. There is no need for the i=1 and i=i+1 commands. The 'for' does all that. ...

1 year ago | 0

| accepted

Answered
How do I use for loops and if statements to find numbers in a two dimensional array and replace them?
Use the "linear" form of the array: for i = 1:length(A(:)) if A(i) < 0 % <- [Corrected] A(i) = 0; end ...

1 year ago | 0

Answered
How do i change this " while loop " to a for loop while still arriving to the same end product?
.... for i = 1:maxiter if abs(h) <= tol break end ....

1 year ago | 0

Answered
how can i draw circle in 3D space with 3 point ?
Let your three points be P1=[x1;y1;z1], P2=[x2;y2;z2], P3=[x3;y3;z3], and call the as yet unknown center P0 = [x0;y0;z0]. I wil...

1 year ago | 2

| accepted

Answered
scalar multiplication of two vectors giving me NAN,both are of same dimensions.
A zero in one vector multiplied by a corresponding infinity in the other vector will give a NaN result. You would do well to ch...

1 year ago | 0

| accepted

Answered
I have written a logic for co-occurance matrix but it is taking a lot of time, is there any other to built the logic?
In the code you have written the tests are false the great majority of the cases, and that suggests strongly that the method can...

1 year ago | 0

Answered
Do the inverse operation of this reshape?
You have to know the dimensions of the original array in order to get back to that, in which case you simply do a another ‘resha...

1 year ago | 0

Answered
matrix multiplication with probability
If p is a matrix the same size as A with the probability values you describe, do this: SA = size(A); a = rand(SA); ...

1 year ago | 0

| accepted

Answered
Using normrnd to generate a random sequence
The best answer to your question is, “don’t use ‘normrnd’ for that purpose!” It is very much the wrong distribution for that. ...

1 year ago | 1

| accepted

Answered
I have a textbook that provides me with code and I'm using the code that they have in the textbook, verbatim, on my Mac and it refuses to work.
You have misinterpreted the fifth (last) argument to be entered into the function. You have set it to pi/2 which is so small th...

1 year ago | 0

Answered
Randomise List with Repetitions
Without your restriction as to the number of 20% images, you would be asking for a binary distribution for each set of 12 images...

1 year ago | 0

Answered
Trying to plot a sine wave, getting a straight line.
You have placed your ’n’ variable outside the parentheses for the sine function. That would make it a straight line. It should...

1 year ago | 0

| accepted

Answered
calculate area of boundary of set of 2d-data point
I would advise you to "close" the polygon so that the first point is the same as the last point. Otherwise, Matlab may be a bit...

1 year ago | 0

| accepted

Answered
How to combine two trendline from two figures and find the angle?
polyfit(x,y,1) will give you [p,q] which represents the line y = p*x+q, so ‘p’ will be the slope of such a fitted line. Therefo...

1 year ago | 0

| accepted

Answered
how to select a random number from the existing matrix in each column
[m,n] = size(A); Anew = A(randi(m,[1,n])+m*(0:n-1));

1 year ago | 0

Answered
Physics Quıestion in Matlab
Matlab does not accept indices equal to zero. These can only be positive integers greater than zero. Therefore "x(0)=1;" and "...

1 year ago | 0

Answered
How can I shuffle a matrix
AB = A; AB(2,9,6,13,4,11,8,15) = AB(9,2,13,6,11,4,15,8);

1 year ago | 0

Answered
When solving a system of nonlinear equations, is it possible that some unknowns remain arbitrary?
Many things are possible with a set of equations involving a set of unknowns. The most common situation is that if there are an...

1 year ago | 1

Answered
Randomize a string from input
To obtain a random permutation of 'first_word' you need the 'randperm' function, not 'randi': perm_of_first_word = first_w...

1 year ago | 1

| accepted

Answered
Tabulate shortens array. Why?
The number of rows in the output of 'tabulate' is the number of unique values in the input, so there must have been 19231 unique...

1 year ago | 0

Answered
How can i sum cells that equals in matrix
You can also use the 'all' function: sum(all(diff(a,1,2)==0))

1 year ago | 1

Answered
Converting decimal to binary and vise versa
I’ll assume that the form of the binary version is a row vector, B, of eight ones or zeros, and that the "decimal" number is a d...

1 year ago | 0

| accepted

Load more