Answered
LOOP in matlab (for)
It appears you have multiple variables in your workspace with names such as U_01, U_02, ... U_60 and you want to make more of th...

11 years ago | 2

| accepted

Answered
mex C compiler cannot find .c file
What do you get whey you type: dir yprime.c Also, as a general rule you should *copy* source files from their original d...

11 years ago | 0

Answered
How to solve a matrix with increments
Your code turned into valid MATLAB syntax: %1.152T1 - 1.152T2 = -50974.255 sinx %1.536T1 + 1.536T2 = 50974.255 cosx ...

11 years ago | 0

| accepted

Answered
Retrieving (all) information from a cell array when meeting a predefined condition?
Using logical indexing: a(strcmp(a(:,1),refstring),:)

11 years ago | 0

| accepted

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

11 years ago | 0

| accepted

Answered
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

11 years ago | 1

| accepted

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

11 years ago | 0

| accepted

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

Load more