Answered

Manually write code for a Vector Autoregression

First off, the interior (j) part of your loop doesn't make any sense, for several reasons: (1) Everything inside that loop is b...

Manually write code for a Vector Autoregression

First off, the interior (j) part of your loop doesn't make any sense, for several reasons: (1) Everything inside that loop is b...

alrededor de 1 mes ago | 0

| accepted

Answered

Speed up a programme with for loops?

You can vectorize this easily for huge computational savings: %% Using loops tic E0=10; A = zeros(10000,10000); for k...

Speed up a programme with for loops?

You can vectorize this easily for huge computational savings: %% Using loops tic E0=10; A = zeros(10000,10000); for k...

alrededor de 2 meses ago | 0

Answered

plotting real solution of matrix system - time issue

I may be misunderstanding things, but it looks to me like the equation you're trying (det(S)=0) to solve is an 8th-order polynom...

plotting real solution of matrix system - time issue

I may be misunderstanding things, but it looks to me like the equation you're trying (det(S)=0) to solve is an 8th-order polynom...

alrededor de 2 meses ago | 0

Answered

Plotting a function of a function with piecewise limits

It's the x(t) that shows up in your definition of f_1: t is a vector of real numbers (including non-integers), so x(t) is not a ...

Plotting a function of a function with piecewise limits

It's the x(t) that shows up in your definition of f_1: t is a vector of real numbers (including non-integers), so x(t) is not a ...

2 meses ago | 0

Answered

How can I debug this?

The error is because if you end up in the "otherwise" case of your switch(B), the variable Position doesn't ever get defined, so...

How can I debug this?

The error is because if you end up in the "otherwise" case of your switch(B), the variable Position doesn't ever get defined, so...

2 meses ago | 0

| accepted

Answered

Optimization Problem definition the function

When you do f = @(x) ... the variable f isn't a function, but a function handle, i.e., a sort of "pointer" that allows you to ...

Optimization Problem definition the function

When you do f = @(x) ... the variable f isn't a function, but a function handle, i.e., a sort of "pointer" that allows you to ...

2 meses ago | 0

| accepted

Answered

Point registration - How to get the eigenvectors to have a consistent direction?

This isn't my area of expertise, but one simple "orientation" test is as follows. Consider two scalars and . One way to check w...

Point registration - How to get the eigenvectors to have a consistent direction?

This isn't my area of expertise, but one simple "orientation" test is as follows. Consider two scalars and . One way to check w...

2 meses ago | 0

Answered

Finite difference problem showing NaN value

When M>=2, in the last line of your code, Rt_inc(M+1)=(v-1)*(rt_inc(M)^2)*((rt_inc(M+1)-rt_inc(M))/dt)/Sr(M); because rt_inc(M...

Finite difference problem showing NaN value

When M>=2, in the last line of your code, Rt_inc(M+1)=(v-1)*(rt_inc(M)^2)*((rt_inc(M+1)-rt_inc(M))/dt)/Sr(M); because rt_inc(M...

2 meses ago | 0

| accepted

Answered

How to calculate multiple array at once?

load NEEDHELP n = numel(TEST); meanVolt = zeros(1,n); for j = 1:n meanVolt(j) = mean(TEST(j).data.Voltage_measured(1...

How to calculate multiple array at once?

load NEEDHELP n = numel(TEST); meanVolt = zeros(1,n); for j = 1:n meanVolt(j) = mean(TEST(j).data.Voltage_measured(1...

2 meses ago | 1

| accepted

Answered

Help with storing values for the loop I created want to store them with where they are located on the vector

Is this what you're after? vector = [4 1 6 9 2 1 8 3]; [sorted,sortinds] = sort(vector) sorted = 1 1 2 3 ...

Help with storing values for the loop I created want to store them with where they are located on the vector

Is this what you're after? vector = [4 1 6 9 2 1 8 3]; [sorted,sortinds] = sort(vector) sorted = 1 1 2 3 ...

2 meses ago | 0

Answered

Finding specific peaks in noisy data

This exercise looks like it involves some subejctivity. For example, in the second plot, the "peak" on the left isn't really a p...

Finding specific peaks in noisy data

This exercise looks like it involves some subejctivity. For example, in the second plot, the "peak" on the left isn't really a p...

2 meses ago | 0

Answered

Reducing the number of count/values in each bin in MATLAB

In this line: Count_Liquid = (Count_Liquid + histcounts(CTT_liquid, Intervals_CTT)) the variable Count_Liquid is computed usin...

Reducing the number of count/values in each bin in MATLAB

In this line: Count_Liquid = (Count_Liquid + histcounts(CTT_liquid, Intervals_CTT)) the variable Count_Liquid is computed usin...

2 meses ago | 0

| accepted

Answered

I'm Trying to run iterations until convergence.

Well, you haven't actually told us what the problem you're encountering is, but right away I can see several problems. First, yo...

I'm Trying to run iterations until convergence.

Well, you haven't actually told us what the problem you're encountering is, but right away I can see several problems. First, yo...

2 meses ago | 0

Answered

Out of memory when converting symbolic matrix into function or by simplifying it

First, it's worth pointing out that if you call whos, symbolic variables always show up as 8 bytes. That's not because that's li...

Out of memory when converting symbolic matrix into function or by simplifying it

First, it's worth pointing out that if you call whos, symbolic variables always show up as 8 bytes. That's not because that's li...

2 meses ago | 0

| accepted

Answered

How to find the roots along a real line?

Numerical solvers are not guaranteed to find all roots of an expression. That's what's happening here. The algorithm vpasolve is...

How to find the roots along a real line?

Numerical solvers are not guaranteed to find all roots of an expression. That's what's happening here. The algorithm vpasolve is...

2 meses ago | 1

| accepted

Answered

How would one proceed to plot this?

What is u supposed to be? Some kind of vector you've previously defined? If so, and assuming u is a column vector whose j-th ele...

How would one proceed to plot this?

What is u supposed to be? Some kind of vector you've previously defined? If so, and assuming u is a column vector whose j-th ele...

2 meses ago | 1

Answered

Format a matrix with entries displayed as exact values

I'm not sure exactly what you're after. Here are some possibilities >> format short >> disp(AB) 0 1.0000 1.000...

Format a matrix with entries displayed as exact values

I'm not sure exactly what you're after. Here are some possibilities >> format short >> disp(AB) 0 1.0000 1.000...

2 meses ago | 0

| accepted

Answered

How can I create different colors in the plotted chart for a lot of data

Are you trying to plot 70 different data series on the same plot? If so, Matlab's default color scheme won't give you 70 differe...

How can I create different colors in the plotted chart for a lot of data

Are you trying to plot 70 different data series on the same plot? If so, Matlab's default color scheme won't give you 70 differe...

2 meses ago | 1

Answered

how to find the next maximum value in column of the matrix which is different at the index of the first

I'm not aware of any built-in function. You'll probably have to write one yourself. Something like: function [mxs,mxinds] = mym...

how to find the next maximum value in column of the matrix which is different at the index of the first

I'm not aware of any built-in function. You'll probably have to write one yourself. Something like: function [mxs,mxinds] = mym...

2 meses ago | 0

| accepted

Answered

Unable to perform assignment because the left and right sides have a different number of elements

Your varibles k1, k2, k3, and k4 are vectors, so when you do the line near the bottom of your loop Nw(i+1)=Nw(i)+step/6*(k1+2*k...

Unable to perform assignment because the left and right sides have a different number of elements

Your varibles k1, k2, k3, and k4 are vectors, so when you do the line near the bottom of your loop Nw(i+1)=Nw(i)+step/6*(k1+2*k...

2 meses ago | 0

| accepted

Answered

Impose to a vector not to have zero elements

speed(n,:)=max(sol.y(N+1,:)-sum(sol.y(N+2:N+n,:),1), 0);

Impose to a vector not to have zero elements

speed(n,:)=max(sol.y(N+1,:)-sum(sol.y(N+2:N+n,:),1), 0);

2 meses ago | 0

Answered

Working with complex numbers in the Symbolic Math Toolbox. Why does angle(A) returns atan2(sin(alpha),cos(alpha)) instead of just alpha?

This seems to be the result of a gap in MATLAB's symbolic logic. Your assumption assume(alpha>-pi & alpha<pi) should be enoug...

Working with complex numbers in the Symbolic Math Toolbox. Why does angle(A) returns atan2(sin(alpha),cos(alpha)) instead of just alpha?

This seems to be the result of a gap in MATLAB's symbolic logic. Your assumption assume(alpha>-pi & alpha<pi) should be enoug...

2 meses ago | 1

| accepted

Answered

Trying to assign a 3x1 matrix to the 1st iteration of a for loop.

If y is an array that's tracking values of a 3-element vector as you iterate on k, then you need to make y a matrix. If I've und...

Trying to assign a 3x1 matrix to the 1st iteration of a for loop.

If y is an array that's tracking values of a 3-element vector as you iterate on k, then you need to make y a matrix. If I've und...

2 meses ago | 1

| accepted

Answered

Displaying output for each iteration

It's printing on every iteration, it's just printing it all on one line so it looks like only one thing is getting printed. The...

Displaying output for each iteration

It's printing on every iteration, it's just printing it all on one line so it looks like only one thing is getting printed. The...

2 meses ago | 0

Answered

how to solve this system of equation? (not sure what it's called/)

syms fo fa n t % note you had f0 instead of fo here in your original post eqn1 = fo*cosd(t)+fa*sind(15)==0; eqn2 = fo*sind(t)...

how to solve this system of equation? (not sure what it's called/)

syms fo fa n t % note you had f0 instead of fo here in your original post eqn1 = fo*cosd(t)+fa*sind(15)==0; eqn2 = fo*sind(t)...

3 meses ago | 0

Answered

Sparse matrix multiplication complexity and CPU time

Assuming by A^T you mean the transpose of A, and assuming you already have A and A^T stored, then yes, the complexity of A^T*A s...

Sparse matrix multiplication complexity and CPU time

Assuming by A^T you mean the transpose of A, and assuming you already have A and A^T stored, then yes, the complexity of A^T*A s...

3 meses ago | 1

| accepted

Answered

Indexing arrays of binned data

Index in position 1 exceeds array bounds (must not exceed 1). This error is an indexing error, which suggests to me that one or...

Indexing arrays of binned data

Index in position 1 exceeds array bounds (must not exceed 1). This error is an indexing error, which suggests to me that one or...

3 meses ago | 0

Answered

How to store iteration while loop result?

If you only expect a relatively small number of iterations to occur, then the following will work fine: x0sv = []; fxsv = []; ...

How to store iteration while loop result?

If you only expect a relatively small number of iterations to occur, then the following will work fine: x0sv = []; fxsv = []; ...

3 meses ago | 0

Answered

What is the solution for "Error using griddedInterpolant The grid vectors must contain unique points."

You're interpolating based on the gridpoints located in column J of your Excel file. Each gridpoint must be unique (i.e., differ...

What is the solution for "Error using griddedInterpolant The grid vectors must contain unique points."

You're interpolating based on the gridpoints located in column J of your Excel file. Each gridpoint must be unique (i.e., differ...

3 meses ago | 1

| accepted

Answered

Solving nonlinear equations that include integrals with embedded variables

Your call to fsolve: fsolve('LD', UnknownGuess, options, I, P, n, Mo, l, E) Your function syntax for LD: Eq = LD(Unknown, I, ...

Solving nonlinear equations that include integrals with embedded variables

Your call to fsolve: fsolve('LD', UnknownGuess, options, I, P, n, Mo, l, E) Your function syntax for LD: Eq = LD(Unknown, I, ...

3 meses ago | 0