Answered
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;

11 years ago | 2

| accepted

Answered
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

11 years ago | 0

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

11 years ago | 0

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

11 years ago | 0

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

11 years ago | 1

| accepted

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

11 years ago | 3

| accepted

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

11 years ago | 0

| accepted

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

11 years ago | 0

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

11 years ago | 0

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

11 years ago | 0

Answered
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')

11 years ago | 0

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

11 years ago | 1

| accepted

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

11 years ago | 0

| accepted

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

11 years ago | 0

| accepted

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

11 years ago | 2

| accepted

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

11 years ago | 1

| accepted

Answered
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]; %...

11 years ago | 1

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

11 years ago | 1

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

11 years ago | 2

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

11 years ago | 1

| accepted

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

11 years ago | 1

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

11 years ago | 1

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

11 years ago | 1

| accepted

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

11 years ago | 3

| accepted

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

11 years ago | 1

| accepted

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

11 years ago | 1

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

11 years ago | 1

Answered
Converting 1x1 matrix into 200x1 with same value?
myVector(1:200,1) = singleValue;

11 years ago | 1

| accepted

Answered
error in c-compiler
Type the following at the command line. When asked if you want MATLAB to look for compilers, press Enter: mex -setup If ...

11 years ago | 0

Answered
Error using horzcat Dimensions of matrices being concatenated are not consistent. Please help.
Use the debugger to pause the code at the error. Then examine the dimensions of the variables involved and figure out what the p...

11 years ago | 0

Load more