답변 있음
From where is this exp in syms calculus?
The solution space has multiple values, not just one. The solver has parameterized the solution space for you. There are multi...

5년 초과 전 | 0

| 수락됨

답변 있음
simulate a dice throw
doc randi E.g., for a single throw you could use randi(6)

5년 초과 전 | 1

| 수락됨

답변 있음
Why do I get "Array indices must be positive integers or logical values" error when using?
k is 3.5 So y(k-1) is y(2.5) and y(k-2) is y(1.5). The indexes are not positive integers, hence the error. Maybe you meant ...

5년 초과 전 | 0

| 수락됨

답변 있음
How to fill mxArray with mxGetComplexDoubles?
No, this would not be expected to work. In the first place, you need to use mxDOUBLE_CLASS to create the mxArray, not mxSINGLE_...

5년 초과 전 | 0

| 수락됨

답변 있음
The spacecraft free-fall math model
See this link for an example of the parachute problem: https://www.mathworks.com/matlabcentral/answers/516385-code-not-working-...

5년 초과 전 | 0

답변 있음
Satellite Orbit, Friction Acceleration Function
See this link for an example that uses atmospheric drag with a satellite (in this case a satellite falling to Earth): https://w...

5년 초과 전 | 0

답변 있음
Fibonacci Series Using Recursive Function
All of your recursive calls decrement n-1. Eventually you will wind up with the input n=0 and just return v=0, which is not wha...

5년 초과 전 | 0

답변 있음
How to fix error: "Index in position 1 is invalid. Array indices must be positive integers or logical values"
Type the following at the command line: dbstop if error Then run your code. When the error occurs, the code will pause with a...

5년 초과 전 | 0

| 수락됨

답변 있음
Why do I get this error message "Array indices must be positive integers or logical values."
You forgot to multiply between the y and (y-1) Z = x(:).^2.*y.*(y-1).*(y+1); Also, make sure to use element-wise operators (wi...

5년 초과 전 | 0

답변 있음
pointers in object-oriented matlab programing
MATLAB does not have variable pointers ... at least not in the sense of C/C++ like you are probably alluding to.

5년 초과 전 | 0

답변 있음
Recursion in matrix calculation
This uses recursive calls (CalDet calls CalDet with smaller matrices until the size is 1x1). I.e., the recursion continues all ...

5년 초과 전 | 1

답변 있음
How C++ gets struct values from Matlab
Looks like your strings are char type and not the newer string type. So you can try the following: mxArray *mx; char *name; ...

5년 초과 전 | 0

답변 있음
Checking whether two complex matrices are equal
You can't rely on floating point calculations to give exact results. See this link: https://ch.mathworks.com/matlabcentral/ans...

5년 초과 전 | 2

| 수락됨

답변 있음
IMU orientation using AHRS filter
I haven't used either of those functions, but from reading the doc maybe you need to use the conjugate of the quaternions in you...

5년 초과 전 | 1

답변 있음
Quick way to Invert the matrix (A+D) where the inverse of matrix A is known and the matrix D is diagonal.
Are the values in D small compared to A^-1 ? Maybe you can make use of one of the forms listed here: https://en.wikipedia.org/...

5년 초과 전 | 0

답변 있음
How do I program the orbit of a particle that is experiencing Gravity & Radiation Force Pressure?
The differential equation is simply Newton's F = ma, where m is the mass of the object (M1) and a is the acceleration of the obj...

5년 초과 전 | 0

답변 있음
Numerical integration RK4 for the given data
E.g., a VERY SIMPLISTIC approach showing one step of Euler integration dt = some delta time value q = [1,0,0,0]; % Initial qua...

5년 초과 전 | 0

| 수락됨

답변 있음
How to convert this 2D code segment with random number into the FORTRAN code?
For your particular case, looks like the MATLAB code could reduce to: Nx = 4; Ny = 4; c1 = 0.12; rr = 0.0001; D = c1 + rr*(...

5년 초과 전 | 1

답변 있음
Matrix multiply result different from loops
MATLAB calls 3rd party BLAS library code to do matrix multiply. This is a highly optimized multi-threaded library. The orderin...

5년 초과 전 | 1

| 수락됨

답변 있음
Why does defining a system of ODEs a different, but similar way yield very different solutions?
Do you simply need to apply that factor in the 6th spot? (kred(t)*CNiIIIH - kox(t)*CNiIIH - k2*CNiIIH*CH)*(96485.33289/1e9);

5년 초과 전 | 0

답변 있음
atan2(0,0) is not undefined (NaN)
This is a documented convention. https://ch.mathworks.com/help/matlab/ref/atan2.html

5년 초과 전 | 0

답변 있음
How to use not equal in for loop
You could use a while loop. E.g., t = 0; while( t ~= 1 ) % code % at some point, either set t=1 or break out of loop...

5년 초과 전 | 0

답변 있음
Given that A is a sparse matrix, norm(A(i,:)) takes a very long time. Why and can one do better ?
Will you eventually need all of the rows? E.g., do this once at the beginning outside the loop n = sqrt(sum(A.^2,2)) And then...

5년 초과 전 | 0

답변 있음
8bit binary sub string to unsigned integer in matlab
doc bin2dec

거의 6년 전 | 0

답변 있음
Indexing in fields of a struct
Loops are what is needed here, but you can hide the loops behind function calls if you want. E.g., k = 3; % the number you are...

거의 6년 전 | 0

| 수락됨

답변 있음
Using FP16 data in MATLAB
If you have R2018b or later, you can fread as uint16 and then typecast into half type. E.g., % Generate some sample data >> d...

거의 6년 전 | 1

| 수락됨

답변 있음
I'm new to matlab and am trying to sort an array in ascending order without using the sort command. How would I rectify this?
This is a "bubble sort" and you have two problems. First, as mentioned by Walter, is your indexing max value is one too big. Y...

거의 6년 전 | 1

답변 있음
Preallocating a sparse matrix, then entering values column by column takes too much time. Is there a more efficient way ?
The problem is that every time you change the elements of Q, even if it is only one element change, MATLAB generally has to copy...

거의 6년 전 | 0

답변 있음
How to optimize matrix multiplication speed?
This looks like a covariance matrix update to me. The matrix multiplies are already done by highly optimized multi-threaded com...

거의 6년 전 | 0

답변 있음
How to limit calculation precision?
You can get about that precision (a little less) by using the half data type: https://www.mathworks.com/help/fixedpoint/ref/hal...

거의 6년 전 | 1

더 보기