Answered
how can someone make a 1234,123,12,1 pattern in a triangle
Here is a start for you. It might be easier to construct the loop using backwards indexing. E.g., n = 6; for k=n:-1:1 ...

11 years ago | 0

| accepted

Answered
Hi all nice holiday ?
Is this what you want? It generates the random numbers, then in a loop uses the k'th sample r(k). a = 0.04; b = 0.07; ...

11 years ago | 0

| accepted

Answered
How do I create a random variable which follows the Rademacher Distribution?
One way: n = number of samples; % <-- The number of samples you want mp = [-1 1]; % <-- The two values you want as o...

11 years ago | 2

| accepted

Answered
How to resolve the "Index exceeds matrix dimensions" error ?
Type the following at the command line: dbstop if error Then run your program. When the error occurs, the program will ...

11 years ago | 0

| accepted

Answered
Reading a .mat file in c/c++
Use the mat API functions from the library (e.g., matOpen, matGetVariable, etc): http://www.mathworks.com/help/matlab/read-an...

11 years ago | 3

| accepted

Answered
Question on function variables i.e. ~
It is mainly to avoid cluttering your workspace with variables you don't need in a "neat" manner. E.g., [~,I] = max(abs(xc)...

11 years ago | 1

Answered
Matrix dimensions do not agree
My guess is you meant that division in your xinf calculation to be element-wise. E.g., change the / to ./ as follows: xinf ...

11 years ago | 0

| accepted

Answered
'new' in MEX file causes crash
You don't show enough code. E.g., these lines: getMatrixSize(prhs[0], rows, cols, "rhs0"); getMatrixSize(prhs[1], rows...

11 years ago | 0

Answered
R2012b convert HEX to binary and extract individual bits
Is this all you are trying to do? bits01_05 = bin2dec(BinaryNumber(1:5)); bits06_06 = bin2dec(BinaryNumber(6:6)); bit...

11 years ago | 0

| accepted

Answered
Get rid of unwanted output
You overwrite your input variable i with your for loop index i, which always goes up to 9. So do this instead: function out...

11 years ago | 0

| accepted

Answered
what does it mean wcode=w64(1,:);
It means that at that point in the code, there is no variable in the current workspace with the name w64.

11 years ago | 0

Answered
Verify my For Loops
The reason you are getting all 7's in your answer is because i+j is always 7, so you are assigning 7 to each element. And the i...

11 years ago | 2

| accepted

Answered
How can I use a vector value as a row index to modify an element?
Y = X; m = (1:size(X,1))'; % Generic row index vector g = bsxfun(@lt,m,V); % Logical indexes of the 0's Y(g) = 0; ...

11 years ago | 0

Answered
Specify compiler options for mex command
Maybe try some variant of the following: filename = your source code file name compiler_option = '/GL /fp:fast'; mex(...

11 years ago | 1

| accepted

Answered
Deleting Rows of a Matrix HELP
When you delete rows in a for loop, the indexing changes so the for loop indexing is no longer valid. Instead of using a for loo...

11 years ago | 0

| accepted

Answered
-3 + 5j in polar form
You could use the following: Z = -3 + 5j; R = abs(Z); theta = angle(Z); http://www.mathworks.com/help/matlab/ref/a...

11 years ago | 0

Answered
In an assignment A(I) = B, the number of elements in B and I must be the same.
t is a vector, so the expressions involving t that you have written will be vectors. You can't stuff a vector into a single elem...

11 years ago | 0

| accepted

Answered
Function of a function\
x = a\b; doc mldivide http://www.mathworks.com/help/matlab/ref/mldivide.html?searchHighlight=mldivide

11 years ago | 0

| accepted

Answered
result of ismember is wrong in my code correct in command window
I suspect this is just floating point issues. Reading from a file may read in all of the precision of the numbers (i.e., precis...

11 years ago | 0

| accepted

Answered
'Not equal too' statement not working
Another method using the function isequal, which is useful for arrays: if ~isequal(UserResponse,RequiredCoordinat...

11 years ago | 0

Answered
Matrix Transfer of elements
Did you mean to assign the entire row? E.g., this? path(i,:)=SearchStart; Just guessing here since SearchStart is a 1x2 m...

11 years ago | 0

Answered
How to exit a for loop if the conditions within it are already met?
Sounds like you have two conditions, your relative error calculation and your guess being close enough. If you want to forgo the...

11 years ago | 0

Answered
How can I break from an inner loop but still continue the outer loop?
One way is to use an auxiliary variable. E.g., for t=1:1:473; breakinner = false; for Lfn=1.0005:0.0005:5; ...

11 years ago | 4

Answered
How to store a vector under a for loop
theta(delta) = r1*sin(delta)*u; % <-- Added the (delta) indexing You will also need to change some of your matrix operators...

11 years ago | 0

| accepted

Answered
I want to create a nxn matrix with all 0s and n randomly placed 1s
n = whatever; x = zeros(n); x(randperm(n*n,n)) = 1;

11 years ago | 0

| accepted

Answered
cell of matrixes to cell of array
newC = cell(size(C)); for k=1:numel(C) M = C{k}'; newC{k} = M(:); end

11 years ago | 0

Answered
multiplying each non zero element of a sparse matrix by a certain number
W = S; G = logical(S); W(G) = W(G) .* P(:); Note: This preserves the sparse attribute of S. I.e., if S is sparse, th...

11 years ago | 3

Answered
Make this matrix multiplication more efficient
a = (B(1:n,:)*(A*b)).^2; You dimensions for B look a little strange to me, since your calculations do not use all of the ro...

11 years ago | 0

| accepted

Answered
Compensating Accelerometer readings from gravity i.e., finding out the direction of movement
First, there are too many unknowns. E.g., what are the coordinate systems of the quaternions (ECI to BODY, or what)? Scalar firs...

11 years ago | 0

Load more