Respondida
loop through same equation
In your loop, y(i) and y(i-1) are scalar elements of y, not vectors. You need to use different syntax for the vectors. E.g., y...

más de 6 años hace | 0

Respondida
Appending an asterisk to my output matrix if x > y
Add the ASCII codes for space and asterisk in the 4th column and print that column as a string. E.g., newMatrix(:,4) = ' '; ne...

más de 6 años hace | 0

Respondida
Math function and plotting
You need to change that matrix divide operator / to an element-wise divide operator ./ with the dot.

más de 6 años hace | 1

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

más de 6 años hace | 0

| aceptada

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

más de 6 años hace | 0

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

más de 6 años hace | 1

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

más de 6 años hace | 0

| aceptada

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

más de 6 años hace | 0

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

más de 6 años hace | 3

| aceptada

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

más de 6 años hace | 0

| aceptada

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

más de 6 años hace | 0

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

más de 6 años hace | 2

| aceptada

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

más de 6 años hace | 1

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

más de 6 años hace | 1

| aceptada

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

más de 6 años hace | 1

| aceptada

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

más de 6 años hace | 0

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

más de 6 años hace | 0

| aceptada

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

más de 6 años hace | 0

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

más de 6 años hace | 0

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

más de 6 años hace | 1

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

más de 6 años hace | 0

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

más de 6 años hace | 2

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

más de 6 años hace | 0

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

más de 6 años hace | 0

| aceptada

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

más de 6 años hace | 1

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

más de 6 años hace | 0

| aceptada

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

más de 6 años hace | 0

| aceptada

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

más de 6 años hace | 0

| aceptada

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

más de 6 años hace | 0

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

más de 6 años hace | 1

| aceptada

Cargar más