답변 있음
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...

7년 초과 전 | 2

답변 있음
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...

7년 초과 전 | 6

| 수락됨

답변 있음
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...

7년 초과 전 | 3

| 수락됨

답변 있음
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...

7년 초과 전 | 0

| 수락됨

답변 있음
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., ...

7년 초과 전 | 0

| 수락됨

답변 있음
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);

7년 초과 전 | 1

| 수락됨

답변 있음
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...

7년 초과 전 | 3

답변 있음
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...

7년 초과 전 | 1

| 수락됨

답변 있음
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...

7년 초과 전 | 0

답변 있음
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...

7년 초과 전 | 0

| 수락됨

답변 있음
[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...

7년 초과 전 | 0

| 수락됨

답변 있음
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...

7년 초과 전 | 1

답변 있음
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...

7년 초과 전 | 0

답변 있음
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...

7년 초과 전 | 0

| 수락됨

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

7년 초과 전 | 2

| 수락됨

답변 있음
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...

7년 초과 전 | 1

| 수락됨

답변 있음
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...

거의 8년 전 | 1

답변 있음
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...

거의 8년 전 | 0

답변 있음
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...

거의 8년 전 | 0

답변 있음
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...

거의 8년 전 | 0

| 수락됨

답변 있음
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...

거의 8년 전 | 0

답변 있음
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...

거의 8년 전 | 3

답변 있음
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 ...

거의 8년 전 | 0

| 수락됨

답변 있음
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...

거의 8년 전 | 0

답변 있음
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...

거의 8년 전 | 1

답변 있음
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...

거의 8년 전 | 0

| 수락됨

답변 있음
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...

거의 8년 전 | 0

| 수락됨

답변 있음
How to construct a customized outer function for 2 vectors?
Start with a vectorized function handle, e.g., f = @(x,y)x.^y Then use bsxfun, e.g., result = bsxfun(f,A,B); Not...

거의 8년 전 | 0

| 수락됨

답변 있음
How to pass equation to a function where the function subplots graphs?
y_exact_overdamped is a function handle. You pass that into your function which gets it as y_exact. You then assign this to y1. ...

거의 8년 전 | 0

답변 있음
ToFile from SImulink read into C++ standalone program
Time series objects are classdef OOP objects. To get at the underlying data in them, you will need to use the mxGetProperty API ...

거의 8년 전 | 0

더 보기