Answered

Error trying to solve 2 Second ODE

Just looking at func.m, it appears you pass in a 4-element x vector, but you only return a 2-element a vector. You need to retu...

Error trying to solve 2 Second ODE

Just looking at func.m, it appears you pass in a 4-element x vector, but you only return a 2-element a vector. You need to retu...

24 Tage ago | 0

Answered

vpa doesn't seem to work

You are passing a double into vpa( ), so your precision is lost before you even call it. You could pass in a string instead: n ...

vpa doesn't seem to work

You are passing a double into vpa( ), so your precision is lost before you even call it. You could pass in a string instead: n ...

26 Tage ago | 1

| accepted

Answered

A function to find prime number

Your function doesn't return anything, so when you try to use its output you get an error. Change this: function isPrime(numbe...

A function to find prime number

Your function doesn't return anything, so when you try to use its output you get an error. Change this: function isPrime(numbe...

26 Tage ago | 0

| accepted

Answered

Rolling all six numbers on a six sided die

This: v = zeros(1,NToys); NRolls = 0; needs to be inside your Trial loop so that it resets for each trial. A simpler way to ...

Rolling all six numbers on a six sided die

This: v = zeros(1,NToys); NRolls = 0; needs to be inside your Trial loop so that it resets for each trial. A simpler way to ...

27 Tage ago | 0

Answered

Need help Euler Method

The fundamental thing you are doing wrong is that you don't have the proper size state vector. For a 1st order equation, the st...

Need help Euler Method

The fundamental thing you are doing wrong is that you don't have the proper size state vector. For a 1st order equation, the st...

27 Tage ago | 0

| accepted

Answered

How can I add values of an array as an input into the ode45 function ?

What is the size of I? What is the DE you are solving? Maybe just dropping the (t) will work: dydt= (-I/(3600*Q)); Or maybe ...

How can I add values of an array as an input into the ode45 function ?

What is the size of I? What is the DE you are solving? Maybe just dropping the (t) will work: dydt= (-I/(3600*Q)); Or maybe ...

27 Tage ago | 0

| accepted

Answered

double differentiation and double integration of sine wave

"... when differentiating my position to get velocity and acclereation i did work out all three of them by hand, quite sure it i...

double differentiation and double integration of sine wave

"... when differentiating my position to get velocity and acclereation i did work out all three of them by hand, quite sure it i...

27 Tage ago | 0

Answered

Comparison of two Vektors with different size to find variables

E.g., x = ismember(b(:,1:2),a(:,1:2),'rows'); c = b(x,:); Depending on how the times were constructed, you might need to use ...

Comparison of two Vektors with different size to find variables

E.g., x = ismember(b(:,1:2),a(:,1:2),'rows'); c = b(x,:); Depending on how the times were constructed, you might need to use ...

27 Tage ago | 0

| accepted

Answered

How to transfer parameter between C and fortran

Maybe the Fortran compiler settings are compiling the default integer as 8-byte integers. Try forcing the Fortran to use 4-byte ...

How to transfer parameter between C and fortran

Maybe the Fortran compiler settings are compiling the default integer as 8-byte integers. Try forcing the Fortran to use 4-byte ...

27 Tage ago | 0

| accepted

Answered

How to sort a matrix in a random order

E.g., >> x = reshape(1:24,4,6) x = 1 5 9 13 17 21 2 6 10 14 18 22 3 7 ...

How to sort a matrix in a random order

E.g., >> x = reshape(1:24,4,6) x = 1 5 9 13 17 21 2 6 10 14 18 22 3 7 ...

28 Tage ago | 0

| accepted

Answered

can someone help me to solve this error (This statement is not inside any function. (It follows the END that terminates the definition of the function "RK4".)

Looks like your plot( etc ) and legend( etc ) lines are stuck inbetween two functions. Did you intend them to be inside a scrip...

can someone help me to solve this error (This statement is not inside any function. (It follows the END that terminates the definition of the function "RK4".)

Looks like your plot( etc ) and legend( etc ) lines are stuck inbetween two functions. Did you intend them to be inside a scrip...

28 Tage ago | 0

Answered

making array in for loop

Maybe prior to the loop define Alignment as a cell array to hold your results: Alignment = cell(10000,1);

making array in for loop

Maybe prior to the loop define Alignment as a cell array to hold your results: Alignment = cell(10000,1);

etwa ein Monat ago | 0

| accepted

Answered

Why is my function generating a vector? Please help?

A uniform random number between a and b is: u = a + rand*(b-a) Generate two of these with a = -0.05 and b = 0.05 and then do t...

Why is my function generating a vector? Please help?

A uniform random number between a and b is: u = a + rand*(b-a) Generate two of these with a = -0.05 and b = 0.05 and then do t...

etwa ein Monat ago | 0

Answered

Can someone explain the concept of B= null(A) in simple words?

The columns of B form basis vectors for the "null space" of A. Any linear combination of the B columns, when multiplied by A, w...

Can someone explain the concept of B= null(A) in simple words?

The columns of B form basis vectors for the "null space" of A. Any linear combination of the B columns, when multiplied by A, w...

etwa ein Monat ago | 1

Answered

Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 5-by-1.

Looks like Cd and rho are vectors. So the result of those calculations on the right hand side will be vectors. But you are tryin...

Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 5-by-1.

Looks like Cd and rho are vectors. So the result of those calculations on the right hand side will be vectors. But you are tryin...

etwa ein Monat ago | 0

| accepted

Answered

What can I use instead of VPA?

See the following FEX submissions by John D'Errico: https://www.mathworks.com/matlabcentral/fileexchange/36534-hpf-a-big-decima...

What can I use instead of VPA?

See the following FEX submissions by John D'Errico: https://www.mathworks.com/matlabcentral/fileexchange/36534-hpf-a-big-decima...

etwa ein Monat ago | 1

Answered

Two equal datetime values showing as unequal when compared?

This is often just a display issue. E.g., >> s = datetime(2017,3,24,9,5,0.1) s = 24-Mar-2017 09:05:00 >> t = datetime(20...

Two equal datetime values showing as unequal when compared?

This is often just a display issue. E.g., >> s = datetime(2017,3,24,9,5,0.1) s = 24-Mar-2017 09:05:00 >> t = datetime(20...

etwa ein Monat ago | 0

Answered

How can I multiply square submatrices more efficiently?

Here is the naive mex code. Could probably be made faster by doing the for-loop in parallel or trying to optimize cache hits, b...

How can I multiply square submatrices more efficiently?

Here is the naive mex code. Could probably be made faster by doing the for-loop in parallel or trying to optimize cache hits, b...

etwa ein Monat ago | 1

| accepted

Answered

big difference in execution time in approximately the same code

The matrix multiply operator * in MATLAB calls highly optimized compiled BLAS library code in the background. The BLAS library ...

big difference in execution time in approximately the same code

The matrix multiply operator * in MATLAB calls highly optimized compiled BLAS library code in the background. The BLAS library ...

etwa ein Monat ago | 2

| accepted

Answered

This is a question from numerical methods asking to explain what the code does for 12 marks.

https://en.wikipedia.org/wiki/Newton%27s_method

This is a question from numerical methods asking to explain what the code does for 12 marks.

https://en.wikipedia.org/wiki/Newton%27s_method

etwa ein Monat ago | 0

| accepted

Answered

how to use passing by value and passing by reference

In the background, MATLAB effectively passes all variables into functions as shared data copies. This has the same effect as pas...

how to use passing by value and passing by reference

In the background, MATLAB effectively passes all variables into functions as shared data copies. This has the same effect as pas...

etwa ein Monat ago | 0

Answered

matrix dimensions must agree error

Well, tau is only two elements and w is a lot more than that, so you can't multiply them element-wise like you are attempting to...

matrix dimensions must agree error

Well, tau is only two elements and w is a lot more than that, so you can't multiply them element-wise like you are attempting to...

etwa ein Monat ago | 0

| accepted

Answered

Monte Carlo integration of sin(x)

This is what you are currently doing with the "random counting in an area" method: To make it go from -1 to +1 instead, you c...

Monte Carlo integration of sin(x)

This is what you are currently doing with the "random counting in an area" method: To make it go from -1 to +1 instead, you c...

etwa ein Monat ago | 0

Answered

How can i split the values of vector into group of 5?

Assuming your vector is divisible by 5, you could do this: v = your vector g = reshape(v,5,[]); % reshape v into a 5 x N matri...

How can i split the values of vector into group of 5?

Assuming your vector is divisible by 5, you could do this: v = your vector g = reshape(v,5,[]); % reshape v into a 5 x N matri...

etwa ein Monat ago | 0

Answered

Runge-Kutta function with a second order ODE

I'm still confused about your initial conditions and what y0 and y1 are. But let's back up a bit. For a 2nd order ODE, your st...

Runge-Kutta function with a second order ODE

I'm still confused about your initial conditions and what y0 and y1 are. But let's back up a bit. For a 2nd order ODE, your st...

etwa ein Monat ago | 0

| accepted

Answered

how to call struct array in subroutine

See this related thread: https://www.mathworks.com/matlabcentral/answers/480829-what-is-the-best-way-to-insure-that-all-of-my-f...

how to call struct array in subroutine

See this related thread: https://www.mathworks.com/matlabcentral/answers/480829-what-is-the-best-way-to-insure-that-all-of-my-f...

etwa ein Monat ago | 0

Answered

For and if loops

RT([3,6],v) is the syntax to use for the 3rd and 6th rows of the v'th column of RT. But this is of course going to be two eleme...

For and if loops

RT([3,6],v) is the syntax to use for the 3rd and 6th rows of the v'th column of RT. But this is of course going to be two eleme...

etwa ein Monat ago | 0

Answered

Matlab Solving Differential Equation using Runge Kutta

In this line: k_1 = F_xy(x(i), xy(i)); You've got xy(i) as an argument, but there is no xy variable. I think you meant y(i) h...

Matlab Solving Differential Equation using Runge Kutta

In this line: k_1 = F_xy(x(i), xy(i)); You've got xy(i) as an argument, but there is no xy variable. I think you meant y(i) h...

etwa 2 Monate ago | 0

Answered

How can i write MacLaurin Sequence for 1/1+x2

An outline of your code could look something like this: x = _____; % you fill in the blank here, or get an input from the user ...

How can i write MacLaurin Sequence for 1/1+x2

An outline of your code could look something like this: x = _____; % you fill in the blank here, or get an input from the user ...

etwa 2 Monate ago | 0

Answered

Multiplication of complex matrices

There are two different operators: ' is the complex conjugate transpose .' is the straight transpose (no complex conjugate), n...

Multiplication of complex matrices

There are two different operators: ' is the complex conjugate transpose .' is the straight transpose (no complex conjugate), n...

etwa 2 Monate ago | 1

| accepted