Respondida
im trying to create a while loop for random numbers and it says if its even or odd
Change this while times < 20 to this while Ecounter < 20 and change this Ecounter = 0+1; to this ...

casi 6 años hace | 0

Respondida
The Body Mass Index, or BMI
Just get rid of these lines: function BMI=findbmi(Weight,Height)

casi 6 años hace | 1

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

casi 6 años hace | 0

| aceptada

Respondida
simulate a dice throw
doc randi E.g., for a single throw you could use randi(6)

casi 6 años hace | 1

| aceptada

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

casi 6 años hace | 0

| aceptada

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

casi 6 años hace | 0

| aceptada

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

casi 6 años hace | 0

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

casi 6 años hace | 0

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

casi 6 años hace | 0

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

casi 6 años hace | 0

| aceptada

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

casi 6 años hace | 0

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

casi 6 años hace | 0

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

casi 6 años hace | 1

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

casi 6 años hace | 0

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

casi 6 años hace | 2

| aceptada

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

casi 6 años hace | 1

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

casi 6 años hace | 0

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

casi 6 años hace | 0

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

casi 6 años hace | 0

| aceptada

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

casi 6 años hace | 1

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

casi 6 años hace | 1

| aceptada

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

casi 6 años hace | 0

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

casi 6 años hace | 0

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

casi 6 años hace | 0

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

casi 6 años hace | 0

Respondida
8bit binary sub string to unsigned integer in matlab
doc bin2dec

casi 6 años hace | 0

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

casi 6 años hace | 0

| aceptada

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

casi 6 años hace | 1

| aceptada

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

casi 6 años hace | 1

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

casi 6 años hace | 0

Cargar más