Answered
Is there a function that returns a vector or array or list of values obtained by applying a function to margins of an array or matrix?
A bit clunky, but this works and makes no assumptions about f being vectorized: n = numel(x); m = numel(y); M = array...

11 years ago | 0

Answered
Why am I receiving this error when trying to implement sparse?
The variable markovChain (or s1 or s2) has 0's in it, and you are attempting to use this for indexes when building the sparse ma...

11 years ago | 0

Answered
How can I determine the angle between two vectors in MATLAB?
This topic has been discussed many times on the Newsgroup forum ... if I looked hard enough I'm sure I could find several Roger ...

11 years ago | 11

Answered
%16.8f what does the 16 and 8 means
In %16.8f, 16 is the minimum number of total characters to print for the value and 8 is the number of digits to print after the ...

11 years ago | 0

| accepted

Answered
Why i am getting this error ...? please help
Type the following at the MATLAB prompt: dbstop if error Then run your code. When the error occurs the program will paus...

11 years ago | 0

Answered
Please help me to solve this question
Step through the code in the debugger to see what is happening and what the variable values are. That will give you insight int...

11 years ago | 0

Answered
coverting binary to decimal and vise versa
Assuming you are only interested in positive integers (that are not too large), realize that mod(x,2) will pick off the least si...

11 years ago | 0

Answered
Possible combinations for elements of five vectors
allcomb(D1,D2,D3,D4,D5) or allcomb(D1,D2,D3,D4,D5,'matlab') Depending on which indexing order you want. You can f...

11 years ago | 1

| accepted

Answered
Comparing to string vectors
The intersect function works for me, as long as I start with cell arrays as you have stated. E.g., >> date1 = {'12-10-1992'...

11 years ago | 0

Answered
Help with dec2bin conversion
You are trying to solve what is essentially a very difficult problem when using floating point arithmetic. First, the number 0.1...

11 years ago | 0

| accepted

Answered
How can I extract the all the rows that contain a certain string from a cell array?
Don't use == (the eq function) to compare strings since this is an element-by-element operator. Use a function meant for this pu...

11 years ago | 2

| accepted

Answered
How to use user input data in my code?
name = input(prompt,'s'); load([name '.txt'])

11 years ago | 1

| accepted

Answered
Contradictions in ANY and ALL?
Only TMW can explain their reasoning, but this behavior is specifically documented for both functions. What doesn't seem to be d...

11 years ago | 0

Answered
How to delete a row if it doesn't follow a pattern
Assuming the pattern in the last column must be 1-2-1-2-...etc exactly [m,n] = size(a); expected = 1; % initialize expec...

11 years ago | 0

Answered
Replace vector duplicates with unique numbers
One way: D = [2,4,5,4,1,2] n = numel(D) C = setxor(D,1:n) [U id] = unique(D) ix = setxor(id,1:n) D(ix) = C(r...

11 years ago | 1

| accepted

Answered
int2str returns the wrong result
Your original number has too many digits to store in a double precision number. E.g., num2strexact(731671765313306249192251...

11 years ago | 1

| accepted

Answered
Converting cell to struct with field names
The 3rd argument is the dimension of the cell array to use for the fields, not the number of fields. You've got 5 field names, ...

11 years ago | 1

| accepted

Answered
How to find matrix column & row max & min output as vector?
For a matrix, use two indexes to separate the logic for the columns (or rows). E.g., for the column max values using a variation...

11 years ago | 0

| accepted

Answered
Indexing n cell elements at a time
E.g., is this the type of indexing you want? for j = 1:4:100 % Index through 1x100 cell temp = values(j:j+3); % Pic...

11 years ago | 0

| accepted

Answered
Combinations of the rows of matrices
A slightly different order for the rows than you have listed, but contains the same content: [X Y Z] = meshgrid(1:size(a1,1...

11 years ago | 0

Answered
finding column # that contains an integer in a matrix
X = your matrix; indices = find(any(X==5)); % columns that have the number 5 in them

11 years ago | 0

| accepted

Answered
malloc error when making multiple subsequent calls to mex file
First thing I noticed was these lines: int dims[3] = {N,N,R}; int dims_Rel[2] = {R,N}; : plhs[...

11 years ago | 0

Answered
Exponentiation of Matrix Columns by different Powers
C = bsxfun(@power,A,b);

11 years ago | 0

Answered
How can I determine if elements in an array are equal to a scalar
Output = cellfun(@(x)isequal(x,3),a);

11 years ago | 0

| accepted

Answered
Problem using BLAS routine ztbsv.c
All of the BLAS and LAPACK complex storage is based on an original Fortran standard, which has real and imaginary parts interlea...

11 years ago | 0

| accepted

Answered
I have 60*3 Matrix. i have store it into L. then i have to allocate these value as (L1, L2, L3, L4.......L20) for 20 matrix. how can i allocate. please tell me command or allocation
If you are trying to create 20 different variables named L1, L2, ..., L20, this is a bad idea. It will be difficult to write goo...

11 years ago | 0

| accepted

Answered
I am trying to eliminate a loop from an operation. If it can't be done, I'm trying to understand why using a loop to create a string command for eval is so much faster than doing the more conventional calculation.
Assuming you want the indexes themselves: n = whatever; C = mat2cell(X,size(X,1),ones(1,size(X,2))); my_indices = fin...

11 years ago | 0

Answered
Issue with fprint() on a (2*3) matrix
1) A is being printed in the order the elements are in memory. Since the elements are being stored by columns, the order in memo...

11 years ago | 0

| accepted

Answered
Finding the path between two points
E.g., a somewhat "linear" path allowing "diagonal" jumps (more than one index can change at a time): Point1 = whatever; ...

11 years ago | 0

| accepted

Answered
I need to generate a warning statement and I am not exactly sure how.
E.g., put this at the end of your function: if( yrs > 10 ) warning('Goal not reached in 10 years'); end

11 years ago | 0

Load more