Answered
How can I find the position of a real number in a vector?
Welcome to the world of floating point arithmetic. The number you are searching for cannot be represented exactly in IEEE doubl...

6 years ago | 0

| accepted

Answered
Runge Kutta 4th Order Method
When solving the EOM for w_dot you should get a minus sign: https://en.wikipedia.org/wiki/Euler%27s_equations_%28rigid_body_dyn...

6 years ago | 0

Answered
How to tell if a value is an integer?
Welcome to the world of floating point arithmetic. (77/29) cannot be represented exactly in IEEE double precision arithmetic, s...

6 years ago | 1

Answered
Boolean help with arrays
You have incorrect syntax. First a big hint: A(:) turns A into a column vector containing all of the elements in a column orde...

6 years ago | 0

| accepted

Answered
How to generate a vector of random numbers whose total must be equal to 1?
See this FEX submission by Roger Stafford: https://www.mathworks.com/matlabcentral/fileexchange/9700-random-vectors-with-fixed-...

6 years ago | 0

Answered
ode45 dynamics rocket around earth equation of motion
You have the wrong initial conditions. They should be: r0 rdot0 theta0 thetadot0 But you have vtheta0 in that last spot in...

6 years ago | 3

| accepted

Answered
how to extract n rows in a matrix column iteratively?
Depending on what you are doing downstream in your code, it may make more sense to simply reshape and then access the columns. ...

6 years ago | 0

| accepted

Answered
how to add zeros to the beginning and end
Lots of ways to do this. Depends on how many zeros you want. E.g., a = [0 0 a 0 0]; Or, m = 2; n = 2; a = [zeros(1,m) a z...

6 years ago | 0

Answered
Keep the negative value while squaring
Change this Velocity(t)^2 to this abs(Velocity(t)) * Velocity(t)

6 years ago | 2

| accepted

Answered
Satellite orbital parameter problem
Use the orbital geometry to calculate the true anomaly at the ascending node, and then plug that value into the conic equation t...

6 years ago | 1

Answered
Creating 100x1 vector in matlab for TDMA Method
A = what you have already constructed d = repmat([2.5;2.0;1.5;1.0],25,1); Then code up your TDMA. https://en.wikipedia.org/wi...

6 years ago | 1

| accepted

Answered
Reshape a matrix into vector using rows
b = reshape(a.',1,4); MATLAB array memory is column-wise, so in memory the "a" elements are stored 1,3,2,4. The transpose puts...

6 years ago | 1

| accepted

Answered
Problems activating license MATLAB R2013a or R2013b versions.
This is a user forum. For official TMW help on installation and licensing, contact them directly. Click on the "phone" icon at...

6 years ago | 0

Answered
How to convert a sign integer matrix to binary?
Reshaping is fast since it uses a shared data copy instead of a deep data copy. So your three step process isn't going to be sl...

6 years ago | 0

| accepted

Answered
Array indices must be positive integers or logical values.
These lines: L = charpath(D); Lrand = charpath(Drand); clust = meanC/meanCrand; charpath = L/Lrand; look li...

6 years ago | 0

Answered
Matrix dimensions must agree
Yes, you need . in other places. Basically, to do element-wise operations you need to look for all of the x's in your equation ...

6 years ago | 0

Answered
Plot x^2+y^2=4
E.g., since you know it is a circle with radius 2 centered at the origin; ang = 0:0.01:2*pi; x = 2*cos(ang); y = 2*sin(ang); ...

6 years ago | 1

Answered
Matrix n x n with n is integer
Examples, If N is a 5x7 matrix and n is 3, then your function would return N(1:3,5:7), the 3x3 sub-matrix at the top right cor...

6 years ago | 0

Answered
How to solve a second order differential equations with matrices by using "ODE45"?
1/m is a scalar/3x3 hence the error. Normally I would advise backslash here, but that brings up another issue. If M, C, and K ...

6 years ago | 2

Answered
Image read in MATLAB and C
An int is likely 4 bytes on your machine, not 2 bytes. Also the expression "order" by itself evaluates as a pointer to the firs...

6 years ago | 0

Answered
Appending a row vector into a matrix based on given conditions
x = abs(b-60) > abs(b-550); % fixed typo xzplane550 = equakemat(x,:); xzplane60 = equakemat(~x,:); If all the data ends up in...

6 years ago | 0

| accepted

Answered
Is it a mistake that the function sum?
Welcome to the world of floating point arithmetic. https://www.mathworks.com/matlabcentral/answers/57444-faq-why-is-0-3-0-2-0-1...

6 years ago | 1

Answered
return any angle to (0 to 2pi) range
The short answer: mod(x,2*pi) The long answer for this particular mod operation, is that if you want to get the same answer fo...

6 years ago | 0

| accepted

Answered
Precision quandaries: why can I print 64 digits?
What you describe sounds like it is just a display issue. Earlier versions of MATLAB on PC machines used a library print functi...

6 years ago | 0

| accepted

Answered
Grabbing number from array to calculate the numerical derivative
For the version you post, see the diff( ) function along with element-wise divide. E.g., diff(y) ./ diff(x) If that doesn't wo...

6 years ago | 0

| accepted

Answered
Coding a quadratic root finder
I would advise having your logic figure out what situation you have before you start solving things. E.g., something like if( a...

6 years ago | 0

Answered
Numerical solution of ODEs system using ODE45
You've got a 2nd order DE and a 3rd order DE, so the order of your system is 2+3=5, not 6. So your state vector should have 5 e...

6 years ago | 1

| accepted

Answered
Am I doing this right? (a Math formula to Matlab language)
You are on the right track, but have typos in the code due to parentheses issues. A = sum( (x - y).^2 ); B = sum( (x - mean(x)...

6 years ago | 1

| accepted

Answered
Numerical solution of Higher order differential equation using ODE45 and a m. archice
t is a number, not a symbol. So u = sin(t) is a number, not a symbolic function. So doing diff(u) does diff on a single value,...

6 years ago | 0

| accepted

Answered
Write an executable script file (m-file) that takes no inputs and returns the displacement and stored energy of a spring system after prompting the user for the 1) input forces (in N) on the spring and 2) the spring constant (in N/m).
To get you started, simply create an m-file with something like this at the front end: F = input('Input the force on the spring...

6 years ago | 0

| accepted

Load more