Answered

How can I calculate the sum of the absolute error?

Please check the code below. clear all, close all % model F = @(c,x)c(1)+c(2)*x+c(3)*(x.^2-1); % data xk = [-2 -1 0 1 ...

How can I calculate the sum of the absolute error?

Please check the code below. clear all, close all % model F = @(c,x)c(1)+c(2)*x+c(3)*(x.^2-1); % data xk = [-2 -1 0 1 ...

ongeveer 2 jaar ago | 1

| accepted

Answered

Drawing a rotating circle on a sphere

The code should be self-explicative [X,Y,Z] = sphere; % figure figure, hold on axis equal, view([1 1 1]); % sphere wit...

Drawing a rotating circle on a sphere

The code should be self-explicative [X,Y,Z] = sphere; % figure figure, hold on axis equal, view([1 1 1]); % sphere wit...

ongeveer 2 jaar ago | 0

| accepted

Answered

How can you solve a system of second order differential equation, which is not time, but length and radius dependent?

This is not an ODE but a PDE. you should have a look at pdepe

How can you solve a system of second order differential equation, which is not time, but length and radius dependent?

This is not an ODE but a PDE. you should have a look at pdepe

ongeveer 2 jaar ago | 2

| accepted

Answered

We have a column vector and a row vector both of same lengths. How to use sum function to get element wise sum of two vectors and final answer display in row vector

vect3 = vect1.'+vect2 If you want to be sure of the element by element sum, regardles the shape of the two vectors (row or colu...

We have a column vector and a row vector both of same lengths. How to use sum function to get element wise sum of two vectors and final answer display in row vector

vect3 = vect1.'+vect2 If you want to be sure of the element by element sum, regardles the shape of the two vectors (row or colu...

ongeveer 2 jaar ago | 0

| accepted

Answered

How to randomly change element of matrix?

You can use linear indexing % your matrix A = rand(10,100); % create the folder mkdir('storage'); % loop for i = 1:100...

How to randomly change element of matrix?

You can use linear indexing % your matrix A = rand(10,100); % create the folder mkdir('storage'); % loop for i = 1:100...

ongeveer 2 jaar ago | 2

Answered

How to create a series of circle by using a specific radius in cartesian?

Try something like this % anonymous function to plot a circle given the center coordinates and the % radius plotcircle = @(x,...

How to create a series of circle by using a specific radius in cartesian?

Try something like this % anonymous function to plot a circle given the center coordinates and the % radius plotcircle = @(x,...

ongeveer 2 jaar ago | 0

| accepted

Answered

Converting Euler ODE to the MATLAB code

f is an anonymous function f = @(t,y)[-2*y(1)+y(2)+15*cos(t); 2*y(1)-y(2)]; note that your script is not correct, since t is t...

Converting Euler ODE to the MATLAB code

f is an anonymous function f = @(t,y)[-2*y(1)+y(2)+15*cos(t); 2*y(1)-y(2)]; note that your script is not correct, since t is t...

ongeveer 2 jaar ago | 1

| accepted

Answered

How to call a variable matrix from one script to another script

I am not sure I have understtod correctly your problem. I give it a try. I would add an extra layer using an anonymous function...

How to call a variable matrix from one script to another script

I am not sure I have understtod correctly your problem. I give it a try. I would add an extra layer using an anonymous function...

ongeveer 2 jaar ago | 1

| accepted

Answered

How to use ~= operator as constraint function?

You may have a look here or here

How to use ~= operator as constraint function?

You may have a look here or here

ongeveer 2 jaar ago | 0

Answered

How to compare two time signals with different amount of samples?

Use interp1 to resample your vector(s) in order to have the same length clear variables, close all % time vector t1 = 0:1/1...

How to compare two time signals with different amount of samples?

Use interp1 to resample your vector(s) in order to have the same length clear variables, close all % time vector t1 = 0:1/1...

ongeveer 2 jaar ago | 1

Answered

solve efficiently sparse large linear system of equations

I would let the backslash operator work on this matrix sol = L\f; Can you share the original matrix to make other attempts?

solve efficiently sparse large linear system of equations

I would let the backslash operator work on this matrix sol = L\f; Can you share the original matrix to make other attempts?

ongeveer 2 jaar ago | 0

Answered

how to use lsqnonlin to solve conditional equation

The following code should be self explainatory. In the opposite case, simply ask clear all, close all % some dummy params va...

how to use lsqnonlin to solve conditional equation

The following code should be self explainatory. In the opposite case, simply ask clear all, close all % some dummy params va...

ongeveer 2 jaar ago | 0

| accepted

Answered

how to ascribe two values to a parameter such that it will be time dependent

You can pass an extra parameter to RiceG1 function using an anonmymous function. In your driver function add % extra anonimous ...

how to ascribe two values to a parameter such that it will be time dependent

You can pass an extra parameter to RiceG1 function using an anonmymous function. In your driver function add % extra anonimous ...

ongeveer 2 jaar ago | 1

Answered

Can someone help me implement my Kuramoto Model with time delay please?

Your function requires additional parameters. One way to pass them is to use an anonymous function as extra layer % params N =...

Can someone help me implement my Kuramoto Model with time delay please?

Your function requires additional parameters. One way to pass them is to use an anonymous function as extra layer % params N =...

ongeveer 2 jaar ago | 0

| accepted

Answered

Euler's method in matlab

Any ODE solver gives the unknown function(s) as result, not its derivative. So, yes, your results are x and y. Note that in you...

Euler's method in matlab

Any ODE solver gives the unknown function(s) as result, not its derivative. So, yes, your results are x and y. Note that in you...

ongeveer 2 jaar ago | 0

| accepted

Answered

for loop/periodic implementation for number or arrays?

If you want to force the max and min values of your vectors, you can preprocess them x0(x0 < 1 & x0 > nx+1) = 1; If the bounda...

for loop/periodic implementation for number or arrays?

If you want to force the max and min values of your vectors, you can preprocess them x0(x0 < 1 & x0 > nx+1) = 1; If the bounda...

ongeveer 2 jaar ago | 1

| accepted

Answered

How to get this while cycle?

if B and C are matrices, make them vectors using : while any(abs(a_0-a) > 1e-6) || any(abs(B_0(:)-B(:)) > 1e-6) || any(abs(C_0(...

How to get this while cycle?

if B and C are matrices, make them vectors using : while any(abs(a_0-a) > 1e-6) || any(abs(B_0(:)-B(:)) > 1e-6) || any(abs(C_0(...

ongeveer 2 jaar ago | 1

| accepted

Answered

how to find out node coordinates for a simple quad element?

It depends on your data structure: now your qeustion is rather vague. Assuming that you have the node coordinates in the Nx3 ar...

how to find out node coordinates for a simple quad element?

It depends on your data structure: now your qeustion is rather vague. Assuming that you have the node coordinates in the Nx3 ar...

ongeveer 2 jaar ago | 1

Answered

Hwo to normalize a Matrix ?

Following the formula of the OT the normalization has to be done according to the max and min of each row. Note that the matrix ...

Hwo to normalize a Matrix ?

Following the formula of the OT the normalization has to be done according to the max and min of each row. Note that the matrix ...

ongeveer 2 jaar ago | 2

| accepted

Answered

Solving nonlinear DE by reduction of order on matlab

There are some typos in your description of the problem. Here the correct version % your ODE - note that (y(1) and y(2) are exc...

Solving nonlinear DE by reduction of order on matlab

There are some typos in your description of the problem. Here the correct version % your ODE - note that (y(1) and y(2) are exc...

ongeveer 2 jaar ago | 0

| accepted

Answered

creating array based in another array

Here a possible solution, where all arrays you want are in the columns of matrix a2 % number of entries in array 1 n = 5; % c...

creating array based in another array

Here a possible solution, where all arrays you want are in the columns of matrix a2 % number of entries in array 1 n = 5; % c...

ongeveer 2 jaar ago | 0

Answered

Warning: Matrix is singular to working precision.

The matrix is singular because the first three rows are linearly dependent. For example you can obtain row 1 as I guess there...

Warning: Matrix is singular to working precision.

The matrix is singular because the first three rows are linearly dependent. For example you can obtain row 1 as I guess there...

ongeveer 2 jaar ago | 0

Answered

how can i let all number in matrix X between 0~1?

If you want to scale your output in [0 1] you can use this X1 = (X-min(X))/sum(X-min(X)); in fact >> sum(X1) ans = ...

how can i let all number in matrix X between 0~1?

If you want to scale your output in [0 1] you can use this X1 = (X-min(X))/sum(X-min(X)); in fact >> sum(X1) ans = ...

ongeveer 2 jaar ago | 0

| accepted

Answered

how to shift the plotting graph?

Not sure if it is what you want, but you can change the x-axis limits in this way: set(gca,'xLim',[5 20]) to show the portion ...

how to shift the plotting graph?

Not sure if it is what you want, but you can change the x-axis limits in this way: set(gca,'xLim',[5 20]) to show the portion ...

ongeveer 2 jaar ago | 0

Question

Real time GMRES convergence and stop callback

Dear Matlab users, I usually solve large linear problems using gmres. These simulations could last for several tens of hours. T...

ongeveer 2 jaar ago | 0 answers | 0

Answered

Population growth in 7 years

Below you can find the output of the following code % rate r = 0.0063; % years t = 7; % initial population a = 5e6; t =...

Population growth in 7 years

Below you can find the output of the following code % rate r = 0.0063; % years t = 7; % initial population a = 5e6; t =...

meer dan 2 jaar ago | 1

Question

Problem with Simscape variable visibility

Hi all, I have created a simulink model of a circuit using simscape electrical elements. I have also created two callbacks, Ini...

meer dan 2 jaar ago | 1 answer | 0

Answered

how to find parallel of resistors

Maybe it's too late for the OP, but for the records, I usually use an anonymous function with multiple inputs % ananymous paral...

how to find parallel of resistors

Maybe it's too late for the OP, but for the records, I usually use an anonymous function with multiple inputs % ananymous paral...

bijna 3 jaar ago | 1

Answered

Nonlinear equation numerical solution

% params C = 1.2; D = 9420; E = -2.0; B = 0.1973; y0 =...

Nonlinear equation numerical solution

% params C = 1.2; D = 9420; E = -2.0; B = 0.1973; y0 =...

ongeveer 3 jaar ago | 0