Answered
uses of 'zeros' and 'ones' function ?
A couple of examples. zeros is often used to allocate a variable to a known size, then downstream code will fill in the indiv...

11 years ago | 1

| accepted

Answered
How can I make called my function stay in the memory so it can be efficiently run in loop?
The first time you call a function it is parsed and put into memory. It will subsequently stay in memory unless you do somethin...

11 years ago | 0

Answered
Calling LAPACK in MEX files
Some observations: 1) You are using mwSize for the type of integer to use for the LAPACK arguments. Don't do this since this...

11 years ago | 1

| accepted

Answered
How do I convert from a while loop to a for loop?
for i=0:11:109 fprintf('i = %d\n',i) end

11 years ago | 2

| accepted

Answered
How can use "is not equal to" command in matlab? and how terminate or cancel if else??
E.g., if( length(a) ~= length(b) || length(c) ~= length(a) ) % terminate end For the terminate statement, you ...

11 years ago | 0

| accepted

Answered
"depth" of mexMakeArrayPersistent ?
Repeated from this link: http://www.mathworks.com/matlabcentral/newsreader/view_thread/343079 Persistence of mxArray varia...

11 years ago | 1

| accepted

Answered
Undefined function 'eq' for input arguments of type 'struct'
Does this do what you want? if( isempty(s) )

11 years ago | 0

| accepted

Answered
Monte Carlo Method to Estimate Pi
First look at the doc for rand to see how to generate random numbers between -1 and 1: http://www.mathworks.com/help/matlab/r...

11 years ago | 0

Answered
Matrix Division of two 4x1 matrices to get a 4x4 matrix
In general there will be no unique solution for M if the only thing you have to start with is S and Sprime. If you think about i...

11 years ago | 1

| accepted

Answered
How a 4D and 5D matrix or array look like? Can we say that a 4D array is another for of 3d or reshaping the 3d matrix in a bigger 3d matrix. Please reply soon.
You could say: A vector is an array of scalars. A 2D matrix is an array of vectors. A 3D array is an array of 2D matr...

11 years ago | 1

Answered
index must be a positive integer or logical
What are the values of the x vector? E.g., is x(1) equal to 0? This could cause the error.

11 years ago | 0

Answered
[DISCONTINUED] MATLAB Answers Wish-list #4 (and bug reports)
I would like power-users to have the ability to conditionally accept an Answer during the initial 7-day wait period. There have ...

11 years ago | 4

Answered
Create matrix from order of numbers from binary matrix
Caution: Untested x = your matrix of 1's and 0's, xt = x'; s = sum(x(:)); n = numel(x); g = logical(xt); xt(...

11 years ago | 0

| accepted

Answered
I've got a series of numbers ranging from 2 to 50. How can I make matlab make a calculation for each value and put the results as another column right next to it?
E.g., x = [1;2;3;4;5;6]; % <-- Use ; separator to make column vector y = [x,10./x]; % <-- Use element-wise division oper...

11 years ago | 0

| accepted

Answered
Runge-Kutta - Orbital mechanics application
I haven't checked all of your code in detail (and I haven't checked *any* of your orbital mechanics equations at the front), but...

11 years ago | 0

Answered
Finding small vector in big vector
I am not on a machine with MATLAB at the moment to test this, but maybe try the strfind(x,y) function to see if it works with do...

11 years ago | 1

Answered
Convert BIN to HEX
doc fopen doc fread doc dec2hex

11 years ago | 0

| accepted

Answered
How to pull an item and save it into an array/matrix from a Cell that is composed of a Struct
pull(i) is likely a scalar, while myVar{i}.myStruct.myPullItem is likely not a scalar. You are trying to stuff multiple values i...

11 years ago | 0

Answered
Creating sparse matrix in MEX
First, this line is incorrect: A=(double **) mxCalloc( M, sizeof(double)); It should be one of the following instead: ...

11 years ago | 0

| accepted

Answered
??? Error using ==> mtimes Integer data types are not fully supported for this operation. At least one operand must be a scalar.
Generic matrix multiplication for integer data types is not supported by MATLAB. You will need to convert them to a floating po...

11 years ago | 0

| accepted

Answered
calling matlab from c++
Use regular output functions. E.g., ( *after* you assign the value of cresult but *before* you destroy the mxArray mresult ): ...

11 years ago | 0

| accepted

Answered
Get distance covered by a wheel using a gyroscope placed on it
What exactly is in the Gyr_Z1 vector? Are these raw values coming from the gyro? Are they counts? Have they been scaled so that...

11 years ago | 0

Answered
how to fit an array in matrix?
What are the sizes involved? E.g., are you trying to insert a row at the front? E.g., is this what you want (assumes same number...

11 years ago | 0

Answered
Matlab crashes when a C mex file is called
A few observations: unsigned short *hx; : hx = mxGetPr(prhs[0]); The above code will only wo...

11 years ago | 0

Answered
Newton's Method Question
Some hints (I leave it to you to insert them properly into your code): I assume the function handle and function derivative h...

11 years ago | 0

Answered
How do I exclude data coordinates from a preexisting array?
E.g., use logical indexing to isolate the points you want to plot. g1 = data(:,2) < .5 * data(:,1) + .45; % Points less tha...

11 years ago | 0

| accepted

Answered
how to convert output to integer?
Use %d instead of %x for the output format.

11 years ago | 0

Answered
Swapping values within a vector if the one after it is greater than the one before it.
To do the swap you could just use a two-element index vector. E.g., if x(k) > x(k+1) x([k,k+1]) = x([k+1,k]); ...

11 years ago | 1

Answered
How can I get a variable name from a cell?
Once the variable has been put into a cell, you can't recover the original variable name from the cell. If you need that informa...

11 years ago | 0

Answered
using C++ Library (SeqAn) in MATLAB
E.g., You can use the following functions: libfunctions --> Lists the functions available to call calllib --> Calls ...

11 years ago | 0

Load more