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

más de 6 años hace | 2

| aceptada

Respondida
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

más de 6 años hace | 0

| aceptada

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

más de 6 años hace | 0

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

más de 6 años hace | 0

| aceptada

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

más de 6 años hace | 1

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

más de 6 años hace | 1

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

más de 6 años hace | 0

| aceptada

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

más de 6 años hace | 0

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

más de 6 años hace | 0

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

más de 6 años hace | 0

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

más de 6 años hace | 0

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

más de 6 años hace | 2

| aceptada

Respondida
why MATLAB 2019b MEX file is slower
Impossible to say for sure without knowing what your mex function is doing. One thing to note is that in R2018a the storage for...

más de 6 años hace | 3

| aceptada

Respondida
Different complex log values displayed for a "single" input
This is simply the result of floating point calculation artifacts ... not a bug. For instance, your assertion that all of your ...

más de 6 años hace | 0

| aceptada

Respondida
using ode45 for coupled equations
You are mixing syntax here: @(t,x)myfun Either use the syntax @(t,x)expression, where expression is the derivative or use the...

más de 6 años hace | 0

| aceptada

Respondida
For several values of x, use MATLAB to confirm that sinh x = (ex − e−x)/2.
Note that sinh x and ex and e-x in your title would be sinh(x) and exp(x) and exp(-x) in MATLAB code.

más de 6 años hace | 0

Respondida
How can I plot sin(x),sin(2x),...,sin(nx) for an input n all on the same graph? Matrix dimensions must agree error
Modifying your original code without a loop: x=[-2*pi:pi/64:2*pi]; i = input('Enter a positive whole number: \n'); z=[1:i]'; ...

más de 6 años hace | 1

Respondida
Dice rolling & loops
The loop could look something like this: n = numel(a); got5or6 = 0; for k=1:n if( _______ ) % you fill in the blank here...

más de 6 años hace | 0

| aceptada

Respondida
Matlab code for Euler method help
z(i+1) = z(i) + f*h; T(i+1) = T(i) + h; plot(T,z);

más de 6 años hace | 0

Respondida
how to plot euler forward method
Don't change the iteration variable withing the loop. Remove these lines from your code: n=1:11;

más de 6 años hace | 0

Respondida
Creating a loop for game
The name "input" is an existing MATLAB function. It would be best to change this to something else, e.g. n. And use a differen...

más de 6 años hace | 0

Respondida
# of elements mismatch
I'm guessing that the 97th element is empty. What does this show: tl{97}

más de 6 años hace | 1

| aceptada

Respondida
How to Convert Euler Angles (Z-X-Z Convention) to Axis Angles for Image Stack Rotation
An Euler Angle conversion routine by John Fuller that handles all possible conventions can be found here: https://www.mathworks...

más de 6 años hace | 0

Respondida
How to get field value from a struct as a variable in order to use in a code?
Depends on your downstream code whether this is really worth it, but simply e.g. x = yourstruct.x; y = yourstruct.y;

casi 7 años hace | 1

Respondida
Attempting to have a series for sin stop summing when the precision is correct
Inside the sinser function, you never set p to a vector ... it is always just a scalar. If you want to return all of those inte...

casi 7 años hace | 0

Respondida
generate unit vectors based on matrix size
Why not just V(1,2) = 1; Or if you really need to explicitly set those 0’s then start with V(:,2) = 0; followed by the above...

casi 7 años hace | 0

| aceptada

Respondida
mod gives incorrect result
See this thread: https://www.mathworks.com/matlabcentral/answers/338182-how-to-get-mod-of-large-numbers

casi 7 años hace | 1

| aceptada

Respondida
eulers improved method code error
s2=F(x+h/2,y+h*s1/2); %% is it correct for modified euler If "Improved" Euler's Method means "Modified" Euler's Method as your ...

casi 7 años hace | 1

| aceptada

Respondida
Unable to perform assignment because the indices on the left side are not compatible with the size of the right side. What does this mean?
Look at this line: Segment(n_start)=data(n_start:(n_start+ window_size-1)); and simply plug in the numbers for the first itera...

casi 7 años hace | 1

Respondida
Getting an error with the ODE45 function.
You've got your calling code mixed in with your derivative code. You need to code this differently. E.g., one way: In a file c...

casi 7 años hace | 0

| aceptada

Cargar más