Respondida
creating a matrix using integers and other matrices
Exactly what you have already written: c = [1,2,a;3,4,b]; What am I missing?

casi 8 años hace | 0

Respondida
mxMakeArrayComplex() what's for?
If it is your own low level code creating and manipulating the mxArray variables, then I agree with you that this function proba...

casi 8 años hace | 0

Respondida
ODE45, differential equation
Remove the quotes from 'k', and be sure to define k before you call ode45. Also, ode45 is an initial value problem solver, so th...

casi 8 años hace | 0

Respondida
Sparse and binary mask
Try this simple C mex routine. It avoids the overhead you are creating with your sparse alternate stuff. Could maybe be improve...

casi 8 años hace | 2

Respondida
Create array with same number
See this link for a discussion of various methods to do this: <https://www.mathworks.com/matlabcentral/answers/51411-initiali...

casi 8 años hace | 6

| aceptada

Respondida
thread safety of mx mex functions
Here is my short novel on this topic ... To understand how dimensions are stored in mxArray variables, it will help to review...

casi 8 años hace | 3

| aceptada

Respondida
Create a For Loop
Simply adjust your expectations of how to use indexing. E.g., let S(1) mean the same thing as S0 S(2) mean the same thin...

casi 8 años hace | 0

| aceptada

Respondida
What does "Error: ()-indexing must appear last in an index expression" mean?
You need to use multiply operators between the ( ) expressions to multiply them. MATLAB does not do this automatically. E.g., ...

casi 8 años hace | 0

| aceptada

Respondida
how can i generate a random number between two float numbers
This is one of the examples in the rand doc: val = mnval + rand*(mxval-mnval);

casi 8 años hace | 1

| aceptada

Respondida
Is there a faster way to change zeros to ones and ones to zeros?
Assuming you have *only* 0's and 1's in your array, here is another way that also keeps the class of the result as uint8: A...

casi 8 años hace | 3

Respondida
A fast way to perform sparse matrix-free product with a vector
Assuming the vectors are 3-tuples of row, column, and value, and that all of the variables involved are full double vectors, her...

casi 8 años hace | 1

| aceptada

Respondida
How do I make a function?
You can use a function handle for this. E.g., F = @(n) P*(1+i).^n I'll leave it to you to plug in appropriate values an...

casi 8 años hace | 0

Respondida
Populating values across a cell
There is nothing in your loop body that uses the index pp other than the data_pro{pp} assignment, so every data_pro{pp} is going...

casi 8 años hace | 0

| aceptada

Respondida
[1 1 2 2 3 3] --> [11 22 33]?
Start with this outline: x = your initial variable of values [m,n] = size(x); result = zeros(___,___); % <-- you fil...

casi 8 años hace | 0

| aceptada

Respondida
Mex inplace change problems R2015b and later
One potential workaround is to change an element of the variable after the assignment to force a deep copy. E.g., >> x = 1...

casi 8 años hace | 1

Respondida
Undefined reference to mexPrintf for simple helloworld program
Your code is a standard mex routine that can be compiled and run at the MATLAB command line prompt as follows: mex hellowor...

casi 8 años hace | 0

Respondida
Newton Raphson equation trig functions
Instead of doing all of this as symbolic, it would probably have been simpler to use function handles and work in double. That b...

casi 8 años hace | 0

| aceptada

Respondida
Assembly of matrices using for loop
Read each individual file into a cell array element, then vertically concatenate the cells all at once.

casi 8 años hace | 2

| aceptada

Respondida
Cross Product is Returning Values way to small to be right
Your vectors are parallel to each other, so the answer *should* be 0. The small number you are getting is just from floating po...

casi 8 años hace | 1

| aceptada

Respondida
Angle between 2 quaternions
Assuming these represent attitude rotations from one coordinate frame to another, if you are simply asking what is the minimum r...

casi 8 años hace | 1

Respondida
I want to make a programming function in which I want to take input any mathematical function like f(x)=sin(x)+x^2. then I take a input x and my function return a value of f(x).but i don't know how can i do?
E.g., s = input('Input a function of x: ','s'); f = str2func(['@(x)' vectorize(s)]); Now you have a vectorized functi...

casi 8 años hace | 0

Respondida
mexGetData() outputs zeros
1) Your check on prhs[1] requires that it is a double, but your pointer is to a float. So that mismatch will never work. f...

casi 8 años hace | 0

Respondida
How to pass a 3d array double[][][] from java to a Matlab function
As long as it arrives as a 3D variable but the dimensions seem backwards, perhaps you only need to permute it. E.g., x = 3D...

casi 8 años hace | 0

| aceptada

Respondida
In MEX, how do I populate an array within a struct within plhs?
I don't have MATLAB or a C compiler handy at the moment, but here are some suggestions: 1) Don't make assumptions with API fu...

casi 8 años hace | 0

Respondida
Do two instances of MATLAB share a workspace?
Just open up two different instances of MATLAB ... they will be two separate processes with two completely independent workspace...

casi 8 años hace | 3

Respondida
Sparse matrix and savings
I don't fully understand your pseudo code, particularly your use of value when indexing into Pattern_Matrix(value). If you just ...

casi 8 años hace | 0

| aceptada

Respondida
Query regarding a sparse complex matrix
The minimum data storage requirement formula for a double m x n sparse matrix with nnz non-zero elements, including the index da...

casi 8 años hace | 0

Respondida
Concatenate dynamical variables [A1;A2;A3.A4;AN) in one script line
Best advice is to back up and rewrite the code that is creating these A1, A2, etc variables in the first place. Instead, use som...

casi 8 años hace | 1

Respondida
Matrix is singular to working precision.
If a square matrix has rows or columns that are very nearly the same, then yes this would cause the matrix to be singular to wor...

casi 8 años hace | 0

| aceptada

Respondida
How Can I solve a system of eight exponential equations?
E.g., h = 0:7; A = bsxfun(@(x,y)exp(x*y*pi*1i/8),2*h',h); % Form your equation matrix y = [0.2165 0.8321 0.7835 0.582...

casi 8 años hace | 0

| aceptada

Cargar más