Answered
Delete row not following pattern
Assuming the pattern in the next-to-last column must be 1-2-1-2-...etc exactly [m,n] = size(a); n1 = n - 1; expected ...

11 years ago | 0

| accepted

Answered
Shifting Elements of a Vector to the right while deleting the last number
A = [1 2 3 4 5 0 0 0] % Original vector p = 3 % index for first element to shift z = 1 % number of spots to shift n =...

11 years ago | 0

| accepted

Answered
Question about using ODE45 to solve a system of linear first order DE's using "initial" conditions specified at a later time
Call ode45 twice. Run it once to integrate backwards in time to the "initial" time you want. Then run it again to integrate forw...

11 years ago | 0

Answered
How to convert a vector into a matrix using reshape ,but what should be the size that should be specified?
If it has fewer elements than originally, you can't directly reshape it into the same size original matrix. You could pad with 0...

11 years ago | 0

Answered
Character Array initialization and creation
The straightforward answer is simply to assign a string to a variable name. E.g., mystring = 'This is a string'; % Initiali...

11 years ago | 0

Answered
Execution of for loop and indexing of strucutres
Is p the loop index? A(p:1) could be empty or could be a scalar depending on what p is. B(:,1) is the first column of B. In...

11 years ago | 0

Answered
change in loop calculation and manual calculation
I think you will find that angle has more significant digits than you are printing. E.g., do this format long g angle ...

11 years ago | 0

| accepted

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

Load more