Answered
How do I reverse the order of two rows of a 4x4 matrix using a for loop?
Did you mean this? A(3,:)=fliplr(A(3,:)); % replaced 1 with a 3 If not, can you describe your problem in more detail...

11 years ago | 0

Answered
How to work out the length of a line
% x = your x coordinate vector % y = your y coordinate vector % d = diff([x(:) y(:)]); d = diff(your 3D point ma...

11 years ago | 2

| accepted

Answered
How to concatenate two matrices in a loop?
Another way using 3-dimensional syntax: n = number of individual matrices you have; R = number of rows per matrix; C ...

11 years ago | 1

| accepted

Answered
generating 10 samples from a binomial using a fair dice.
First, to fix your code I am guessing you are getting error messages about Xx and UR as functions or variables. To concatenate v...

11 years ago | 1

| accepted

Answered
hi, i am using this code.....alfa = inv([r00 r11 r10 r12; r11 r00 r01 r01;... r10 r01 r00 r02; r12 r01 r02 r00])*[r01 r10 r11 r11]; in which i am getting the error"Error using * Inner matrix dimensions must agree"
Assuming all of your rxx variables are scalars: This is a 4x4 matrix: [r00 r11 r10 r12; r11 r00 r01 r01;... % 1st and 2n...

11 years ago | 0

Answered
How to make an angle continuous from -inf to +inf
doc unwrap >> p = (pi/180)*[-177 -178 -179 -180 179 178 177] p = -3.0892 -3.1067 -3.1241 -3.1416 3.1241 ...

11 years ago | 1

| accepted

Answered
Help saving a vector to the workspace that is output from a function.
How are you calling the function? To get the variables in the workspace make sure you are capturing two outputs. E.g., call ...

11 years ago | 0

Answered
Question about loop ranges
The obvious guess would be that some of your results are exactly 0 when you get beyond 2000, so the method of cropping the zero ...

11 years ago | 0

Answered
Help saving the output of a for loop within a function into a vector.
There are vectorized ways to do this (without a loop), but to answer your question directly you could add the index numout onto ...

11 years ago | 0

| accepted

Answered
Calling C/C++ code from MATLAB - example
You can start with the mex examples in the doc: http://www.mathworks.com/help/matlab/ref/mex.html

11 years ago | 0

Answered
How to split a complex vector(H) into equal parts using for loop ?
You could do it with simple indexing k = The set you want to extract (1 = 1st set, 2 = 2nd set, etc) V = H((1:12)+(k-1)*...

11 years ago | 0

| accepted

Answered
Evalaute a string left to right
If you will accept evaluating this all at once, here is one way to do it (only works if the rhs is legit MATLAB syntax, which yo...

11 years ago | 2

Answered
How do I solve this system of coupled differential equations?
Eliminate the 2nd derivative by introducing another variable (i.e., increasing your states). Then you will have a set of 1st ord...

11 years ago | 1

| accepted

Answered
Fibonacci sequence, slightly different.
Looks like your indexing into seq is not quite right. Try this: seq(k)=seq(k-1)+begin;

11 years ago | 0

| accepted

Answered
Creating new vector wich adds previous value with for loop
b = cumsum(a); To fix your explicit loop, don't set b = 0 at each iteration, and use proper indexing into the vectors. E.g....

11 years ago | 2

Answered
i dont quite understand the maclaurium series expansion coding
You can look at this link for a lot of information on series expansions: http://en.wikipedia.org/wiki/Taylor_series In par...

11 years ago | 1

| accepted

Answered
Asking user for input, returning a matrix
You are close. Just a few syntax things to clear up. input('prompt1') uses the explicit string 'prompt1' as the prompt text. ...

11 years ago | 0

Answered
question about addressing matrix elements
Yes. The colon operator when used with three values is starting_value:step:ending_value e.g., 5:-1:2 ans = ...

11 years ago | 0

Answered
Creating a game board for 15-puzzle
You can use reshape to get the random integers into the matrix shape you want. E.g., tiles = reshape(randperm(16)-1,4,4) ...

11 years ago | 1

| accepted

Answered
Can I assign a single value to multiple elements of a cell array without a loop
You almost had the syntax right: myArray(find(cellfun(@isempty,myArray))) = {0} Or you can just use logical indexing and...

11 years ago | 2

| accepted

Answered
Need 3rd dimension indicies for calling values.
m = size(N2s,1); n = size(N2s,2); [~,x] = max(N2s,[],3); % 3rd dimension indexes of the max locations y = (1:m*n)' + ...

11 years ago | 1

| accepted

Answered
creating 30 digits numbers and finding sum
>> "Any idea on how to approach the sum now?" Well, if you had two 30-digit numbers written on a piece of paper, how would yo...

11 years ago | 1

Answered
Sparse linear system of equations
Are you just asking how to construct B_N? E.g., B_N = spdiags(repmat([-1 2 -1],N,1),[-1 0 1],N,N); A_N = speye(N) -...

12 years ago | 0

| accepted

Answered
How to add matrices dimension by dimension without using a loop?
Don't know if this will be faster than your repmat code, but try this: J = bsxfun(@minus,reshape(ldp,1,1,i2,j2,j3),reshape(...

12 years ago | 1

| accepted

Answered
Accessing elements in a multilevel structure
The key to the following is that many operations (e.g., Patients.Lesion) return a comma separated list result, so one uses the [...

12 years ago | 2

| accepted

Answered
How do I create an auto named variable?
Before you do this you should read this link: http://www.mathworks.com/matlabcentral/answers/57445-faq-how-can-i-create-varia...

12 years ago | 2

Answered
Using the text command, how can I display a string genrated from sprintf and a string in one line?
text(mean(xlim),max(ylim),sprintf('p = %4d',p_num)) If you need the leading 0's printed then text(mean(xlim),max(ylim)...

12 years ago | 0

Answered
Help switching variables in a vector using a for loop
You made a good start, but need to fill out the insides of the for-loop. Part d.iii is instructing you to have one line insid...

12 years ago | 0

Answered
Use matrix c\c++ API with row-based indexing
You could transpose it after loading the mat file. Or you could call MATLAB to transpose it for you prior to saving the variable...

12 years ago | 1

| accepted

Answered
Convert binary column vector to decimal
If I understand your question, A is a numeric 52 x 15 matrix consisting of 1's and 0's. For that case you can use: B = bin2...

12 years ago | 3

Load more