Réponse apportée
Taking 3-D matrices out of a 4-D matrix
What is wrong with accessing the 4D array using simple indexing? A(:,:,:,k) for k'th 3D array. You could also use cell arrays,...

plus de 6 ans il y a | 1

Réponse apportée
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...

plus de 6 ans il y a | 0

Réponse apportée
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...

plus de 6 ans il y a | 0

Réponse apportée
Math function and plotting
You need to change that matrix divide operator / to an element-wise divide operator ./ with the dot.

plus de 6 ans il y a | 1

Réponse apportée
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...

plus de 6 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 6 ans il y a | 0

Réponse apportée
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...

plus de 6 ans il y a | 1

Réponse apportée
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...

plus de 6 ans il y a | 0

| A accepté

Réponse apportée
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-...

plus de 6 ans il y a | 0

Réponse apportée
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...

plus de 6 ans il y a | 3

| A accepté

Réponse apportée
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. ...

plus de 6 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 6 ans il y a | 0

Réponse apportée
Keep the negative value while squaring
Change this Velocity(t)^2 to this abs(Velocity(t)) * Velocity(t)

plus de 6 ans il y a | 2

| A accepté

Réponse apportée
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...

plus de 6 ans il y a | 1

Réponse apportée
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...

plus de 6 ans il y a | 1

| A accepté

Réponse apportée
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...

plus de 6 ans il y a | 1

| A accepté

Réponse apportée
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...

plus de 6 ans il y a | 0

Réponse apportée
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...

plus de 6 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 6 ans il y a | 0

Réponse apportée
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 ...

plus de 6 ans il y a | 0

Réponse apportée
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); ...

plus de 6 ans il y a | 1

Réponse apportée
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...

plus de 6 ans il y a | 0

Réponse apportée
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 ...

plus de 6 ans il y a | 2

Réponse apportée
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...

plus de 6 ans il y a | 0

Réponse apportée
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...

plus de 6 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 6 ans il y a | 1

Réponse apportée
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...

plus de 6 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 6 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 6 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 6 ans il y a | 0

Charger plus