Respondida
Projectile motion without drag
You don't define the Vx(k) value before using it, hence the error. Since your Vx values don't change you can fix this error by ...

alrededor de 5 años hace | 1

| aceptada

Respondida
Define x,y,z and evaluate them.
You can define variables simply by typical assignment. E.g., x=5; y=4; etc. You can use * for multiply and ^ for exponentiat...

alrededor de 5 años hace | 0

Respondida
Fortran MEX returns only some elements of output array.
The problem isn't using allocatable variables ... MATLAB mex functions can handle that just fine. The problem is that you are u...

alrededor de 5 años hace | 1

| aceptada

Respondida
System of ODEs with interdependent variables
I would advise writing a derivative function for this. E.g., dydt = myderivative(t,y,gna,gk,gl,Vna,Vk,Vl,I) V = y(1); n = y(...

alrededor de 5 años hace | 0

| aceptada

Respondida
Outlet Limit: water depth and flow rate
You are being asked to write a function that takes H and Q as inputs, and outputs the diameter D. So the function outline would...

alrededor de 5 años hace | 0

Respondida
writing out a quadratic
Use the element-wise operators that include the "dot" (such as .^ instead of just ^), and use the multiply operator * between th...

alrededor de 5 años hace | 0

Respondida
How can I select three random sample of a matrix with minimum separation between samples?
A rejection method is straightforward. Simply make your selections in a forever loop until you get something that works. The a...

alrededor de 5 años hace | 1

| aceptada

Respondida
Cell to matrix under new variable
Do not do this! You are taking a method of storing your data that is easy to maintain and access (e.g., in a loop) and proposin...

alrededor de 5 años hace | 0

Respondida
Adding 2 matrices together in matlab, got errors instead
result = [a,b];

alrededor de 5 años hace | 1

| aceptada

Respondida
Reduce size of multidimensional array
One way using summing: result = squeeze(sum(your_array,3));

alrededor de 5 años hace | 2

| aceptada

Respondida
Euler's code for multiple ODEs
You have two states, so your result should have two values per step. So this code: y = zeros (1,N); % Initialize the Y vec...

alrededor de 5 años hace | 1

Respondida
Runge-Kutta 4th Order on a 2nd Order ODE
All of your derivatives should be with respect to the independent variable x. In the context of your problem, dy/dz does not ma...

alrededor de 5 años hace | 1

| aceptada

Respondida
Something wrong with quat2angle() function?
I agree that this looks like a bug, and you should submit a bug report to TMW for this. I ran it in R2017a and R2020a and both ...

alrededor de 5 años hace | 0

| aceptada

Respondida
want to solve (d^2 y)/(dx^2 )+dy/dx-6y=0 using 4th order Runge-Kutta method with y(0) = 3 and y’(0) = 1
Change your function handle from this f = @(x) (dy^2)/(dx^2 )+dy/dx-6*y; to this f = @(x,y) [y(2);-y(2)+6*y(1)]; The last pa...

alrededor de 5 años hace | 1

| aceptada

Respondida
How to use Bisection Program to locate Roots of given function
If the derivative depended only on the time t then your strategy for finding the maximum/minimum points would be a good one. Ju...

alrededor de 5 años hace | 0

Respondida
ODE45, ODEfunc question
What you might want to do is pass a function handle for this. E.g., in your calling code create the function handle: C1 = what...

alrededor de 5 años hace | 1

| aceptada

Respondida
Runge-kutta 4th order Method Help
All of your F's need to be functions that operate on the current full states. E.g., take this one F_C1 = (xc*yc*((C1.*R1)./(R1...

alrededor de 5 años hace | 0

| aceptada

Respondida
Difference/usage of mwIndex, mwSignedIndex and mwSize in mex C-code
MATLAB provides multiple libraries that mex code links to. There can be both 32-bit and 64-bit versions of functions in the var...

alrededor de 5 años hace | 1

| aceptada

Respondida
Matrix index is out of range for deletion.
You should step through this with the debugger to see what is going on. I.e., click to the left of a line and then run your cod...

alrededor de 5 años hace | 0

Respondida
How to stack k copies of a matrix
B = repmat(A,1,1,k);

alrededor de 5 años hace | 0

Respondida
how can i find the co-ordinates of intersections of two lines?
Suppose you have two line equations: 2x + 3y = 1 3x - 5y = 11 Then you can form the matrix A and the right hand side vector b...

alrededor de 5 años hace | 0

Respondida
difference between euler angles and rotation vector
The rotvecd( ) function gives a scaled rotation axis. I.e., what it would take to do a single rotation of an object on all thre...

alrededor de 5 años hace | 2

| aceptada

Respondida
Cannot input function handles into array
When you do this: basisN0 = @(x)[ 1 ]; basisN1 = @(x)[ 1, x ]; basisN2 = @(x)[ 1, x, x^2 ]; basisN3 = @(x)[ 1, x, x^2, x^3 ]...

alrededor de 5 años hace | 0

| aceptada

Respondida
Analytically finding the roots of polynomials with symbolic variables
Tell the solve( ) function that the max degree of the polynomial is 3 to force explicit solutions for the result: syms a len p...

alrededor de 5 años hace | 0

| aceptada

Respondida
Matlab unable to find solution to cubic polynomial
Tell the solve( ) function that the max degree of the polynomial is 3 to force explicit solutions for the result: syms a p = (...

alrededor de 5 años hace | 0

| aceptada

Respondida
Replacing a for loop with matrix multiplication
result = sum(x.*(inv(SIG)*x)); or result = sum(x.*(SIG\x));

alrededor de 5 años hace | 0

| aceptada

Respondida
How to find the numerical intersection points for a sine and linear function to find solutions ?
You can't do floating point calculations like this and expect the results to match exactly. You would need to use a tolerance t...

alrededor de 5 años hace | 0

Respondida
Solving a Second Order Differential Equation
Here is what I get: >> syms y(t) >> eqn = 4*diff(y,t,2)+32*diff(y,t)+24*y^3 == 192; >> Dy = diff(y,t); >> cond = [y(0)==1.5,...

alrededor de 5 años hace | 0

Respondida
Runge Kutta4 for IVP : y' = ty
Good start! Some corrections noted below. This line y0 = exp(1); should be this according to your text y0 = 3; And this li...

alrededor de 5 años hace | 0

Respondida
Power Method Eigenvectors Code
The only obvious thing I would note is that the following line doesn't accomplish anything because you don't use err in your cod...

alrededor de 5 años hace | 1

Cargar más