Respondida
I've been getting several errors, especially "index must be a positive integer or logical."
In one line you have this: ...+(k2*(... and in the next line you have this: ...+(2*k2(... I assume the 2nd line ...

más de 11 años hace | 0

| aceptada

Respondida
Number of maximum values and maximum values in each column
sum(bsxfun(@eq,A,max(A))) But for your example I get 2 1 3 1 1, not 2 1 3 2 1

más de 11 años hace | 1

| aceptada

Respondida
Using mex to compile with \clr option
Adding a compiler flag to the mex process can be accomplished like this: filename = your source code file name compiler_...

más de 11 años hace | 0

| aceptada

Respondida
How to translate a point on a line by a distance "e" ?
de = e * (A - B) / norm(A - B); D = B + de: C = B - de;

más de 11 años hace | 2

| aceptada

Respondida
Need help writing an if statement involving vectors (2)
Looks like homework to me, so I will just point you in the direction of the following functions: doc diff doc all

más de 11 años hace | 0

Respondida
How to solve: Index of element to remove exceeds matrix dimensions error
I don't see mle_exp created anywhere in your code prior to the line that indexes into it.

más de 11 años hace | 0

Respondida
If-statements won't break when conditions aren't met
This line does no do what you think it does: if beamLength < positions(:) | positions(:) < 0 | ~isnan(positions) If posi...

más de 11 años hace | 0

Respondida
How do get the particles to bounce properly?
You have multiple nested loops that use i for the index variable. These are going to clash and will not work. Change those inner...

más de 11 años hace | 1

| aceptada

Respondida
The cell with the max number of elements
>> c = {1 [1,2] [1,3] [1,2,4] [1,2,4,5] [1,6] [1,2,4,5,7] nan} c = [1] [1x2 double] [1x2 double] [1x3 doub...

más de 11 años hace | 3

| aceptada

Respondida
Populating a matrix with predetermined values
X = zeros(N,N); X(A(:,1)) = A(:,2); X = X';

más de 11 años hace | 0

| aceptada

Respondida
can any one help me i wanna to correct this code ?
Learn to debug. Type this at the command line: dbstop if error Then run your code. It will pause at the error and you wi...

más de 11 años hace | 0

Respondida
Vectorize nested loop to increase efficiency
I am guessing a bit on some of the dimensions, but try this as a vectorized alternative. Speed improvement is going to depend on...

más de 11 años hace | 0

Respondida
Can I have higher precision while counting with long numbers?
If you have the symbolic toolbox you can use vpa. If not, then you might look into these two FEX submissions by John D'Errico: ...

más de 11 años hace | 0

Respondida
a=input('enter number'); b=input('enter number'); c=input('enter operator'); switch c case'+' disp(a+b); case'-' disp(a-b); end
Input variable c as a string. E.g., c = input('enter operator','s')

más de 11 años hace | 0

Respondida
Increase efficiency on nested loops
This gets the inner loops vectorized (gets about a 100x speed improvement on my machine): rho1 = 1 - rho; for t=1:size(d...

más de 11 años hace | 1

| aceptada

Respondida
How to convert this FORTRAN code in to Matlab code
The return statement in Fortran does the same thing as the return statement in MATLAB ... it immediately exits the routine and r...

más de 11 años hace | 0

| aceptada

Respondida
Name Storing in a While Loop
E.g., using a cell array of strings, names = cell(0,2); while (true) f=input('Enter First Name:','s'); l...

más de 11 años hace | 0

| aceptada

Respondida
How do I print a sentence "Hello world!" n number of times?
Since you posted your code I will make some corrections for you: n = input('Enter a number:'); for sentence = 1:n % hav...

más de 11 años hace | 2

| aceptada

Respondida
Name Storage with Repeat loops
Use a while loop if you want to loop repeatedly until some condition is met. E.g., while( true ) f=input('Enter Firs...

más de 11 años hace | 1

| aceptada

Respondida
How to access elements of a structure without the use of a loop ?
Try this: EDITED temp1 = [Running{:}]; % Extract the cells, concatenate into a single struct array temp2 = [temp1.SP]; %...

más de 11 años hace | 1

Respondida
Performance of non-preallocated array
MATLAB's parser can sometimes pre-allocate an array behind the scenes for you (even though you didn't code it that way) if it re...

más de 11 años hace | 1

Respondida
how to change values in matrix by indices
Check out these links for patterns you could use: http://www.mathworks.com/matlabcentral/answers/196631-how-can-i-create-a-ma...

más de 11 años hace | 2

Respondida
Storing values from a for-loop in a matrix. Error: Subscripted assignment dimension mismatch.
Your code runs fine for me with random inputs as follows: Name Size T1 50x1 T_iso1 50x50 ...

más de 11 años hace | 1

| aceptada

Respondida
How to store a Fibonacci Sequence in an array using a for or a while loop?
You have a typo in your pre-allocation. zeros(1,x) should be zeros(1,k). I.e., fib=zeros(1,x); should be fib=zeros(...

más de 11 años hace | 1

Respondida
Hessian matrix 3D plot help
If you just need help with plotting the point, maybe something like this: if abs(Hdet) > 0 && d2fdx2 > 0; Max = [...

más de 11 años hace | 1

Respondida
How do I fix it: Index exceeds matrix dimensions?
You don't update the values for error(i+1) and error1(i+1) like you do for a(i+1) and b(i+1), so on the next iteration they are ...

más de 11 años hace | 1

| aceptada

Respondida
how to select random columns?
If you want only one column at random: x = randi(size(data_sample,2)); column = data_sample(:,x); For more than o...

más de 11 años hace | 3

| aceptada

Respondida
create a function that takes a matrix input, that gives output matrix of odd elements
Have a file called oddelements.m (or whatever name.m you pick), and in that file you would have this: % oddelements: (inser...

más de 11 años hace | 1

| aceptada

Respondida
if an array like [.002 1.1103 0.665 .002]. how can i get [a b c a]?
Not sure what you want. Maybe this? myVector = [.002 1.1103 0.665 .002]; a = myVector(1); b = myVector(2); c = myV...

más de 11 años hace | 1

Respondida
Help with coding taylor expansion of sin(x)
Yes the code for sin(x) is similar to cos(x). You could Bing "Taylor Series for cos x" and click on the first link: http://ww...

más de 11 años hace | 1

Cargar más