Calculate angles correctly between two vectors using the dot product.
Also see this related link for a robust method using atan2 that can recover small angles: https://www.mathworks.com/matlabcentr...

6ヶ月 前 | 0

How can I make memory persistent between calls to a MEX-file in MATLAB?
So, the accepted answer has bugs. Namely: They don't include the header for memcpy They don't check the input argument properl...

6ヶ月 前 | 0

Index in position 1 exceeds array bounds (must not exceed 8).
Here is how to debug these types of errors: Type the following at the command prompt: dbstop if error Then run your code. Whe...

6ヶ月 前 | 0

matlab mex in-place editing via "mxUnshareArray" or similar functionality
So, MATLAB has never officially supported modifying input variables in-place in a mex routine. There are potential side effects ...

6ヶ月 前 | 0

Static methods are unnecessary, right?
I use Constant Properties and Static Methods all the time in classes I am creating. In particular, when I am developing a group...

6ヶ月 前 | 1

Speed of the abs function

7ヶ月 前 | 2

| 採用済み

How would I write these in MATLAB
Depends on what those subscripts mean. E.g., maybe this y41 = -(x41^1.5 * cos(x41)^3) + 40; y42 = x42 * sin(x42^2); or this ...

7ヶ月 前 | 0

| 採用済み

How to find roots of a quartic function with unknown constant coefficients?
You can look here: https://en.wikipedia.org/wiki/Quartic_function But the nature of the roots is going to depend on the value ...

7ヶ月 前 | 0

What calendar system does MATLAB use?
I know this is an old post, but the accepted answer is a bit misleading. MATLAB certainly does use a specific calendar system. ...

7ヶ月 前 | 3

Rungekuttan for a system of 2 DOE functions
It would be better to have a single state vector for your solution so that you can easily compare your results to MATLAB ode45( ...

7ヶ月 前 | 0

How much data does an array take?
The data is held in contiguous memory, so yes for a full real double an NxN matrix would take 8*N^2 bytes for the data. Then the...

8ヶ月 前 | 0

| 採用済み

Multiply matrices in cell array by another matrix
You may be stuck with the loop. There are ways to rearrange and stack things so that you can do everything in a single matrix m...

8ヶ月 前 | 0

Try data = fread(fd, '*int16'); When you use 'int16' for the type to read, MATLAB reads as int16 and then converts to double (...

8ヶ月 前 | 1

| 採用済み

Incorrect Dimensions for matrix multiplication
Because you are using matrix operators instead of element-wise operators. Try this: Rtf=(cosh(m.*Lf)+(h./(m.*Kf)).*sinh(m.*Lf))...

8ヶ月 前 | 0

Why is pow2() slow? Fastest way?
Another way is just to add d to the exponent bits. Probably fastest to do this in a mex routine where edge checking can easily b...

8ヶ月 前 | 0

Values are getting converted to double automatically.
Here is what I get just displaying the character string. I inserted brackets [ ] for concatenation: ab=[0.5,0.75,1,1.25,1.5,2];...

9ヶ月 前 | 2

help with parallelization of matrix operations
Both of these operations can be multi-threaded in the background, but this kind of timing test is not straightforward to do beca...

9ヶ月 前 | 0

Field II kidney example does not work due to "Requested array exceeds the maximum possible variable size." error
At first glance this is the obvious problem in the original source code: The dimensions array needs to be the proper integer si...

9ヶ月 前 | 0

| 採用済み

Is there a classdef startup/initializer method?
When a classdef is first loaded into memory (via object instance creation or static method call etc.), is there a way to get a s...

9ヶ月 前 | 1 件の回答 | 1

### 1

How to update leap seconds
The current version of MATLAB has a function to give you the leap second information that it is using. E.g., [T,vers] = leapsec...

9ヶ月 前 | 2 件の回答 | 0

### 2

A MEX solution to split classdef-defined object arrays into cells
You need to use mxGetProperty( ) to get at the properties of a classdef object. And since this returns a deep copy, no need for ...

9ヶ月 前 | 1

| 採用済み

Why does accessing a multi-dimensional array with fewer indices than its total dimensions not result in an error in MATLAB R2022b?
The accepted answer is misleading. When you access a multi-dimensional array with fewer indexes than its total dimensions, MATLA...

10ヶ月 前 | 3

Create Mex files for Matlab, from .FOR files of Fortran
So, I haven't had access to a Fortran compiler in over 10 years. And as a result I haven't been maintaining any of my Fortran F...

10ヶ月 前 | 0

Unusal error "Current use of the variable is inconsistent with its previous use or definition".
See how the +b is purple? That means MATLAB thinks you are invoking a as a function with +b as a character string input. Hence ...

10ヶ月 前 | 1

| 採用済み

Incorrect datetime UTCLeapSeconds conversion
I am working with leap second data, and as part of the calculations I did this for a particular leap second: dt1 = datetime(197...

11ヶ月 前 | 1 件の回答 | 0

### 1

How to add rows containing zeros to a matrix
E.g., one way using the end syntax: my_matrix = reshape(1:12,3,4) n = 4; % number of rows to append my_matrix(end+n,1) = 0 B...

11ヶ月 前 | 0

error using tranpose (recieving permute error )
If you are trying to transpose the initial 2D pages of your variable, you can do this: pagetranspose(featvales) Or this: d = ...

11ヶ月 前 | 0

Error L2 is not defined
You have a fundamental problem with your code. You have a 2nd order ODE, which means there will be two states you need to carry ...

11ヶ月 前 | 0

Use Indexing for more than 1 dimension of array simultaneously
Yet another way using linear indexing (showing what sub2ind( ) does internally): matrix = rand(10, 3); idx = [1; 2; 2; 3; 1; 2...

11ヶ月 前 | 0

Indexing and turning into column vector
Not really. It's going to be a two-step process no matter how you do it (without resorting to a mex routine, which isn't worth i...

11ヶ月 前 | 0

| 採用済み