Answered
how to construct 4x2 matrix taking value 0 and 1 randomly? No rows should be repeated.
result = dec2bin(randperm(4)-1) - '0';

10 years ago | 0

Answered
How to find arrays in a cell array
c = your cell array x = cellfun(@(x)size(x,1)<5,c); % Logical indexes of arrays with 1st dim < 5 c(x) = []; % Delete t...

10 years ago | 1

| accepted

Answered
Function "fix" with numbers/characters
When you invoke a function without using the parentheses, MATLAB regards all of the inputs as strings. This is true for any func...

10 years ago | 0

Answered
error in solving cell array multiplication
result = cellfun(@(X)bsxfun(@times,Daily_demand(:),X),all_comb_of_routes,'uni',false); btw, you can replace this code: ...

10 years ago | 0

| accepted

Answered
mxCreateStructArray and mxCreateStructMatrix field name memory management
_"Are the field name character arrays copied before being stored internally?"_ Yes. Internally in the mxArray, the field name...

10 years ago | 1

| accepted

Answered
matrix rows combination with all possibilities
E.g., one way to generate the possible combinations all in one 3D matrix, where each 2D plane (the first two dimensions) have th...

10 years ago | 3

| accepted

Answered
difference between | and || in my function
The "|" operator is an element-wise operator, intended to be used on arrays element-by-element. The "||" operator is a short-ci...

10 years ago | 0

| accepted

Answered
My for loop isn't working
Because you are constantly overwriting the value assigned to Co_By(img_line_B,2) with a new value because all of this is inside ...

10 years ago | 1

Answered
Exponential Function of Quaternions - quatexp -- error using scalar quaternions?
This is a bug in the quatexp function. E.g., >> q = [2 0 0 0;2 2*eps 0 0] q = 2.0000 0 0 ...

10 years ago | 1

Answered
Is it possible to declare the matrix is symmetric in advance before multiplication?
No you cannot declare this explicitly. However, in some cases MATLAB will detect that there is a symmetric multiply and call sy...

10 years ago | 1

| accepted

Answered
How to define an array with multiple columns for each parameter in a for loop?
At each iteration, the array sub-section indexing would be: array(:,n*20-19:n*20)

10 years ago | 0

| accepted

Answered
How to change sign in a cell?
respPreStore = cellfun(@uminus,respPreStore,'uni',false);

10 years ago | 0

| accepted

Answered
How can I store function_handle objects in MEX code?
Not sure I follow everything that is going on with your code, but here are my observations: self.setMessageHand...

10 years ago | 2

| accepted

Answered
"nchoosek" function for a matrix whose all elements are 0 or 1
E.g., using a loop: f = find(A); n = numel(f); result = repmat(A,n,1); for k=1:n result(k,f(k)) = 0; end...

10 years ago | 1

| accepted

Answered
Error using mex (line 206) Unable to complete successfully.
You need to visit the link shown above, and install one of the supported compilers that is listed there.

10 years ago | 0

Answered
Whats wrong in those equations?
Use element-wise operators (beginning with a dot) instead of matrix operators. E.g., y1=(0.02049/0.4)*x; y2=(0.59*60./(1...

10 years ago | 0

| accepted

Answered
a mex file in matlab program
To compile the mex routine, first place it in a working directory on the MATLAB path. Then make that your default directory and ...

10 years ago | 0

| accepted

Answered
how can i complement a DNA matrix using a binary vector?
Not quite sure I fully understand, but maybe something like this? mask = mod(X,1) > 0.5; % logical indexes of the characte...

10 years ago | 2

Answered
how can I do this in matlab?
E.g., replacing * with element-wise multiply .* and / with element-wise divide ./ you get (assuming I got your parentheses corre...

10 years ago | 0

| accepted

Answered
return to previous step
Do you mean something like this? % Step A while( true ) % Step B % Step C % Step D if( condi...

10 years ago | 2

| accepted

Answered
using sprintf for floating point numbers
You don't have a semi-colon after this line: optEnergyCostString=sprintf('%g',optEnergyCost) so this result gets display...

10 years ago | 0

| accepted

Answered
Problem with straightforward problem - Can you help?
Use parentheses to separate your || operations from your && operations as necessary. E.g., this line if A=='1' && B...

10 years ago | 0

Answered
How to invert 3D matrices?
Step 1) Get your 2D matrix pages into the 1st two dimensions. This makes each 2D page contiguous in memory and is somewhat of a...

10 years ago | 1

| accepted

Answered
matrix multiplication using bsxfun(@times,a,b)
Not sure if this is the operation you really want from your description: a = 6x7 matrix b = 7x3 matrix c = a * b; % ...

10 years ago | 0

| accepted

Answered
problem with loop while
You never change the value of freq_nat(2,2) inside your while loop, so if the while condition is true at the start of the loop, ...

10 years ago | 0

Answered
Subscripting into an mxArray is not supported for code generation - I think it's the colon that's the issue
What happens if you use explicit indexes? V(1:n,1) = (1/beta)*w;

10 years ago | 0

Answered
Why two equal numbers are not equal?
Already answered by others, but here is a detailed decimal conversion of what is going on with your particular example: >> ...

10 years ago | 1

Answered
How can I extract the numbers which make up a specific number and insert them into an array?
If the number is an integer, e.g., x = your number result = num2str(x) - '0';

10 years ago | 1

| accepted

Answered
How to convert from a for loop to a while loop
Your loop doesn't work because the "continue" statement skips over the Index=Index+1 statement. You need to rewrite things _with...

10 years ago | 0

| accepted

Answered
how i can use ez plot with sin(x)/(1+x^2)
E.g., using default range -2pi to 2pi: fun = @(x) sin(x)./(1+x.^2) ezplot(fun)

10 years ago | 0

Load more