Answered
Error using + Matrix dimensions must agree. Pleasee Helppp
The error message is very clear. The variables you are trying to add do not have compatible sizes. Specifically >> size(R...

8 years ago | 0

Answered
Storing first 200 points from 400 points
X = your vector temp = reshape(X,400,[]); % Get groups of 400 in columns result = reshape(temp(1:200,:),1,[]); % Pick ...

8 years ago | 0

| accepted

Answered
How to return structs properly
A couple of options for you: % Run the loop in reverse. The first iteration pre-allocates the struct for i = 3:-1:1 ...

8 years ago | 2

| accepted

Answered
Sum over cell array of sparse matrices error: Dimension for sparse matrix concatenation must be <= 2.
For your particular example, of course result = a{1} + a{2}; What are the sizes of your real problem? I.e., what are th...

8 years ago | 0

Answered
how do you write the equation f=exp(x)*cos(x)?
I am guessing you want to use the element-wise multiply operator, which has the dot: f = exp(x) .* cos(x);

8 years ago | 2

| accepted

Answered
Create a separate new variable for each element of a vector.
E.g., if you really need to do this for some non-MATLAB reason: for k=1:numel(z_ss) eval(sprintf('z_ss_%d = z_ss(%d)...

8 years ago | 0

Answered
How can I delete some rows of a matrix
A = A(A(:,5)==0,:); or A(A(:,5)~=0,:) = [];

8 years ago | 1

| accepted

Answered
A question about how to solve a second order system by application of ODE and how to apply function xdot
You would pass a function handle to trainDynamics to the ode solver, e.g. ode45, along with a time span and initial value vector...

8 years ago | 0

| accepted

Answered
Need help with a least squares method fitting.
The least squares equations you are trying to solve, using your variable names, are N * a = q' So do this instead (where...

8 years ago | 1

Answered
merging elements into a single cell array
Does this do what you want? C = cellfun(@(c)c(2:end),B,'uni',false); v = cellfun(@(x)x(1),B); u = unique(v); resul...

8 years ago | 0

Answered
How can i use elements from logspace in a for or something to make a sum?
Use element-wise operators with the "dot", e.g., H_1 = abs((2./((j*w).*(j*w)+ 2*1*j*w + 2)));

8 years ago | 0

Answered
Is there a way to get MATLAB to write out a certain number more than once without typing them individually
E.g., >> ones(1,20) ans = Columns 1 through 18 1 1 1 1 1 1 1 1 1 1 ...

8 years ago | 0

Answered
Undefined operator '==' for input arguments of type 'cell'. Error in Elenco (line 13) if tell(i)==c
You don't tell us much about what the variable types and sizes are, so we can only guess. Maybe you need this: if te...

8 years ago | 4

Answered
Alternative for a for loop. How would I write this code without using a for loop?
To get the correct result, you need to make that divide an element-wise divide, and then add up the resulting terms into approx....

8 years ago | 1

| accepted

Answered
MATLAB crashes when running mex file with recursive function
You've got your C mex indexing wrong. Remember, C is 0-based indexing, not 1-based indexing. So in these lines: l = (m...

8 years ago | 0

| accepted

Answered
How do I access and modify only the non diagonal entries in a matrix?
Another way for a square matrix: M = your matrix x = ~logical(eye(size(M))); M(x) = 2*M(x); % <-- or whatever functi...

8 years ago | 0

Answered
Problem With MEX files and DLLs
In general, compiled mex routines are not guaranteed to be compatible between different versions of MATLAB. E.g., the functions...

8 years ago | 0

| accepted

Answered
What should I replace 'mxGetName' with?
Variable name strings used to be a part of the mxArray itself. However, that hasn't been the case for several years now. There...

8 years ago | 1

| accepted

Answered
Check each member of matrix
A = your initial matrix tolerance = 1e-3; while( true ) B = your new matrix if( all(abs(A(:)-B(:))<toleran...

8 years ago | 0

Answered
trying to compile a c file using mexprintf and getting an undefined reference to ‘mexPrintf’
This is somewhat confusing. Including "mex.h" means that the code is intended to be a mex function (compiled into a dll) with t...

8 years ago | 0

Answered
Can't use allocate command in Fortran Mex file
First thing you should do is clean up your argument typing to be consistent. You have the following: mwSignedIndex :: num ...

8 years ago | 2

| accepted

Answered
Is it possible make parallel processing using MEX and OpenMP on Matlab?
For what you are attempting, probably not. Calling MATLAB API functions that allocate/deallocate memory in mex routines is gene...

8 years ago | 1

| accepted

Answered
Finding the geometric mean of inputted numbers??
Use the square brackets [ ] to concatenate your inputs into a vector. E.g., x = geomean([a,b,c]); y = mean([a,b,c]);...

8 years ago | 0

Answered
Loop through hundreds of matrices to change values larger than 1 to 0
result = cellfun(@(c)c.*(c<=1),images,'uni',false);

8 years ago | 1

Answered
How to wrote theta as a matlab code
E.g., theta = pi/4; result = 2*sin(theta); % <-- if theta is in radians theta = 45; result = 2*sind(theta); %...

8 years ago | 2

Answered
Variable Indexing for N-dimension data
The procedure for ':' functionality using the <https://www.mathworks.com/help/matlab/ref/subsref.html?searchHighlight=subsref&s_...

8 years ago | 3

Answered
How can I call MATLAB object's method from C++?
Here is some code based loosely on your singleton design, with an example run. Note that if you clear the mex routine, then the...

8 years ago | 0

Answered
Hi there, I need to correct aberrant IMU euler orientation values occurring secondary to Gimbal lock.
The code you were using was not working because the rhs yaw was not indexed. E.g., to correct this yaw(yaw>180) = yaw(yaw>...

8 years ago | 0

Answered
Matlab Engine - passing strings giving invalid characters
I don't see how this can possibly work, even when called from main( ). It appears you are writing into invalid memory. E.g., ...

8 years ago | 1

Answered
masking data of an image
You don't say what the mask is for. Here is a way to create it: mask = A < 0.02; Here is a way to use it: A(mask) ...

8 years ago | 0

Load more