Respondida
how matlab makes use of C code using mex file
See here: <https://www.mathworks.com/help/matlab/programming-interfaces-for-external-languages.html>

más de 8 años hace | 0

Respondida
how can i run run C-code from MATLAB by calling it from a MEX file.
You can start here: <https://www.mathworks.com/help/matlab/programming-interfaces-for-external-languages.html>

más de 8 años hace | 0

Respondida
Ode45 for first order differential equation (basic)
This is a 1st order ODE, so your variable will be only one element, not two elements. The derivative function will be (using yo...

más de 8 años hace | 0

Respondida
mex setup for openMP using Intel parallel_studio_xe?
How do you currently do the compile? Have you added the appropriate OpenMP directive to the mex compiler options? E.g., see th...

más de 8 años hace | 0

Respondida
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...

más de 8 años hace | 0

Respondida
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 ...

más de 8 años hace | 0

| aceptada

Respondida
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 ...

más de 8 años hace | 2

| aceptada

Respondida
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...

más de 8 años hace | 0

Respondida
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);

más de 8 años hace | 2

| aceptada

Respondida
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)...

más de 8 años hace | 0

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

más de 8 años hace | 1

| aceptada

Respondida
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...

más de 8 años hace | 0

| aceptada

Respondida
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...

casi 9 años hace | 1

Respondida
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...

casi 9 años hace | 0

Respondida
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)));

casi 9 años hace | 0

Respondida
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 ...

casi 9 años hace | 0

Respondida
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...

casi 9 años hace | 4

Respondida
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....

casi 9 años hace | 1

| aceptada

Respondida
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...

casi 9 años hace | 0

| aceptada

Respondida
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...

casi 9 años hace | 0

Respondida
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...

casi 9 años hace | 0

| aceptada

Respondida
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...

casi 9 años hace | 1

| aceptada

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

casi 9 años hace | 0

Respondida
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...

casi 9 años hace | 0

Respondida
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 ...

casi 9 años hace | 2

| aceptada

Respondida
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...

casi 9 años hace | 1

| aceptada

Respondida
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]);...

casi 9 años hace | 0

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

casi 9 años hace | 1

Respondida
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); %...

casi 9 años hace | 2

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

casi 9 años hace | 3

Cargar más