Answered
Subtracting every other row
B = A(3:2:end,1) - A(2:2:end,1);

10 years ago | 0

| accepted

Answered
How to add an array in a structure as a new field?
E.g., c = num2cell([stats.MinorAxisLength]./[stats.MajorAxisLength]); [stats.Ratio] = c{:};

10 years ago | 0

| accepted

Answered
LAPACK error: info -5
BLAS and LAPACK are the math libraries that MATLAB uses for linear algebra. zgeev is the name of one of the routines in the LAP...

10 years ago | 1

| accepted

Answered
Get Equation as Input from User (str2func)
E.g., see this link: http://www.mathworks.com/matlabcentral/answers/297425-could-i-use-a-function-of-x-as-input-like-this-fun...

10 years ago | 1

Answered
Could I use a function of x as input like this ( fun = input(' Function of x = ');) and then when I run the program insert a function of x ?
E.g., input your function as a MATLAB syntactically correct string, then use the str2func function to form a function handle. E....

10 years ago | 2

| accepted

Answered
Set and get structure field with invalid name
I would start with this if you are trying to get stuff from a mat file: http://www.mathworks.com/matlabcentral/fileexchange/4...

10 years ago | 0

Answered
ODE45 and 3D arrays
1) Don't use (:,:,k) subscripting on Phi in your derivative function. ode45 only knows about Phi as a 36-element column vector....

10 years ago | 1

| accepted

Answered
How to convert a 4D matrix from Matlab to C++
C array storage order is reversed from MATLAB storage order. This holds regardless of the number of dimensions. And you certainl...

10 years ago | 0

| accepted

Answered
reading binary file but Hex corresponds to a float
E.g., to convert hex characters to a single float that matches your expectations: >> typecast(int32(hex2dec('42117B5C')),'s...

10 years ago | 0

Answered
compatibility of MEX TYPE for Matlab 2007b and visual studio 2008
LCC is a C compiler only, not a C/C++ compiler combo like Visual Studio et al. To get C++ you have to install a separate C++ co...

10 years ago | 0

| accepted

Answered
Weird error on mex compilation
First, get your mexFunction signature correct and try compiling again. Then we can work on other errors. So first change this: ...

10 years ago | 0

Answered
image flipping without built in commands
Did you mean this? newcat(1:row,1:col,:) = cat(row:-1:1,1:col,:); Or this? newcat(1:row,1:col,:) = cat(1:row,col:-1...

10 years ago | 0

Answered
how to duplicate data length of a workspace ?
E.g., assuming N is divisible by 4: result = repmat(column_vector,N/4,1); If you have to cover cases where N is not divi...

10 years ago | 0

Answered
mex: Link Failed when compile C file
You typically do *not* include header .h files in a mex command. They are generally intended to be included in the source file ...

10 years ago | 1

Answered
Fortran MEX using Cell arrays - crashing Matlab..
You are not creating any output cells, so you are writing to garbage address locations which will eventually result in a MATLAB ...

10 years ago | 0

Answered
How to find non-zero indexes (or value) in row in matrix, and make taken results i and j elements of another matrix Dij?
E.g., using a loop: m = size(A,1); result = zeros(m,1); for k=1:m x = find(A(k,:)); for n=2:numel(x) ...

10 years ago | 1

| accepted

Answered
Is there any means to overload '* (multiplication by the transpose matrix) with my own matrix class?
You could create a special method for this. E.g., tmtimes. Then instead of doing y = A'*x you would do tmtimes(A,x). Or you ...

10 years ago | 0

| accepted

Answered
How to multiply each elements of single matrix one-by-one?
This will multiply every element by every other element: result = Xij(:) * Xij(:)'; % <-- Simple outer product of all the ...

10 years ago | 0

| accepted

Answered
Calculation of Enormous Numbers
Another way: digits 500 Z = vpa(2)^1000 Or see John D'Errico's submissions in the FEX: http://www.mathworks.com/ma...

10 years ago | 0

| accepted

Answered
just installed the Matlab2016b pre-release, do I need to uninstall the previous version (2015b)
No. Multiple versions of MATLAB can co-exist on the same system. Only one of these versions will be the "default" version for ru...

10 years ago | 0

Answered
what is meaning of this error : Undefined operator '*' for input arguments of type 'struct'
It means you tried to use the matrix multiply operator on a struct. E.g., >> a.x = 1:3 a = x: [1 2 3] >> b.y ...

10 years ago | 0

| accepted

Answered
How to return all the rows of a matrix into variables?
variance = diag(w*var_cov*w')

10 years ago | 0

| accepted

Answered
How do I input 2x*sech^2(x^2 - 9) into MATLAB
E.g., vectorized form: y = 2 * x .* (sech(x.^2 - 9)).^2;

10 years ago | 0

| accepted

Answered
Why do functions that call by reference not work when they are linked from other source files in a mex wrapper?
No. You still don't have it correct. I don't know what the discussion on Stack Overflow was, but the problem has nothing to do w...

10 years ago | 1

Answered
how to increment row values of a vector to form a matrix?
E.g., b = bsxfun(@plus,[0;1;2],[1 2 3 4])

10 years ago | 1

Answered
Run simulation 1000 times
Yes. Use an outer for loop. E.g., n = 1000; result = zeros(n,1); for k=1:n % your code result(k) = what...

10 years ago | 1

| accepted

Answered
Checks on Input of MEX Function Leads to Silent Failure
_"What checks do MATLAB MEX functions have on inputs that would cause this function to silently fail?"_ Not knowing what all ...

10 years ago | 0

Answered
adding values to the same column
If the loop isn't too big, you could just append it and dynamically increase the size of out in the loop. E.g., out = []; %...

10 years ago | 0

| accepted

Answered
Repeating string variables to form a new string variable
doc repmat

10 years ago | 0

Answered
Why is Stateflow Coder up-casting variables from uint8 to uint32?
In the C language, the "usual arithmetic conversions" are applied automatically to operands of many unary and binary operations,...

10 years ago | 0

Load more