1,100 total contributions since 2017

Knowledge means knowing where it is written...

Interested in:

- Optimization

- Mathematical Modelling

- Improvement of my programming skills

Answered

Numerical Solution for a System of Three ODEs with Different Constant for Each Time Element

Use interp1 for this. Here is an example: https://de.mathworks.com/matlabcentral/answers/487412-using-ode45-to-solve-differenti...

Numerical Solution for a System of Three ODEs with Different Constant for Each Time Element

Use interp1 for this. Here is an example: https://de.mathworks.com/matlabcentral/answers/487412-using-ode45-to-solve-differenti...

15 hours ago | 0

| accepted

Answered

Text file manipulation, find specific lines, find there a string and replace the specific line with new content

There is a bunch of possibilities to manipulate strings: https://de.mathworks.com/help/matlab/ref/extractafter.html https://de...

Text file manipulation, find specific lines, find there a string and replace the specific line with new content

There is a bunch of possibilities to manipulate strings: https://de.mathworks.com/help/matlab/ref/extractafter.html https://de...

15 hours ago | 0

Answered

Fitting an equation to a Sine Function with NonLinearModel.fit

"...I already tried using the "cftool" function in matlab but it did not have the equation I need...." Did you notice that yo...

Fitting an equation to a Sine Function with NonLinearModel.fit

"...I already tried using the "cftool" function in matlab but it did not have the equation I need...." Did you notice that yo...

20 hours ago | 0

Answered

How to replace last 3 digits in a floating point number by another 3 digits

format long x = -3.141592653589793; a = 287; x_new = sprintf('%.15f',x); x_new(end-2:end) = (sprintf('%d',a)); x_new = st...

How to replace last 3 digits in a floating point number by another 3 digits

format long x = -3.141592653589793; a = 287; x_new = sprintf('%.15f',x); x_new(end-2:end) = (sprintf('%d',a)); x_new = st...

21 hours ago | 0

Answered

I am trying to use ODE45, but I keep getting an error with myfcn saying I don't have enough inputs?

There are at least 4 problems in your code: 1. Split your main code and your ode function: tspan = [0 10]; f0 = [0 0]; ...

I am trying to use ODE45, but I keep getting an error with myfcn saying I don't have enough inputs?

There are at least 4 problems in your code: 1. Split your main code and your ode function: tspan = [0 10]; f0 = [0 0]; ...

23 hours ago | 1

Answered

Having trouble with ODE45 and a System of Ordinary Differential Equations

For every equation you have to input an initial condition. You have 8 but only give 2 initial conditions to ode45. Also your ...

Having trouble with ODE45 and a System of Ordinary Differential Equations

For every equation you have to input an initial condition. You have 8 but only give 2 initial conditions to ode45. Also your ...

1 day ago | 0

Answered

Is there a function to turn ?x2 matrix of coordinates of vertices of a polygon into a ?x4 matrix of coordinates of line segments of that polygon?

Yes, circshift will do the job: A = [2, 4; 5, 6; 6, 6; 8,5] B = [2, 4, 5, 6; 5, 6, 6, 6; 6, 6, 8, 5; 8, 5, 2, 4] % The sol...

Is there a function to turn ?x2 matrix of coordinates of vertices of a polygon into a ?x4 matrix of coordinates of line segments of that polygon?

Yes, circshift will do the job: A = [2, 4; 5, 6; 6, 6; 8,5] B = [2, 4, 5, 6; 5, 6, 6, 6; 6, 6, 8, 5; 8, 5, 2, 4] % The sol...

1 day ago | 0

| accepted

Answered

could anyone help me to display the values in the matrix which are greater than the average value for the following code

B, C and D are not needed, if you use the inbuilt function mean: A=[3.3734 5.1245 4.3729 2.8406 6.5283 4.8144 ...

could anyone help me to display the values in the matrix which are greater than the average value for the following code

B, C and D are not needed, if you use the inbuilt function mean: A=[3.3734 5.1245 4.3729 2.8406 6.5283 4.8144 ...

1 day ago | 0

| accepted

Answered

How to raise a matrix to multiple powers 0 to 100.

Here is a vectorized solution without using a for loop: % Let A be your matrix result = reshape(A(:).^(1:100),size(A,1),size(A...

How to raise a matrix to multiple powers 0 to 100.

Here is a vectorized solution without using a for loop: % Let A be your matrix result = reshape(A(:).^(1:100),size(A,1),size(A...

1 day ago | 0

Answered

How can calcuate the lines of code efficiently?

Yes, you can if you avoid using a loop and vectorize your code - see here: tic %%%code nx=512; ny=nx; dx=1; dy=dx; format...

How can calcuate the lines of code efficiently?

Yes, you can if you avoid using a loop and vectorize your code - see here: tic %%%code nx=512; ny=nx; dx=1; dy=dx; format...

1 day ago | 1

| accepted

Answered

how can i differentiate a constant in simulink?

You already have done everything exactly correct - Simulink also did what is correct. What is the derivative of y(t)=3 with resp...

how can i differentiate a constant in simulink?

You already have done everything exactly correct - Simulink also did what is correct. What is the derivative of y(t)=3 with resp...

2 days ago | 0

| accepted

Answered

Eigenvalues and Eigenvectors of Symbolic Matrix

syms E t H = [E -t -t -t -t 0 0 0 0;-t E 0 0 0 -t -t 0 0;-t 0 E 0 0 0 0 -t -t;... -t 0 0 E 0 -t 0 -t 0; -t 0 0 0 E 0 -t 0...

Eigenvalues and Eigenvectors of Symbolic Matrix

syms E t H = [E -t -t -t -t 0 0 0 0;-t E 0 0 0 -t -t 0 0;-t 0 E 0 0 0 0 -t -t;... -t 0 0 E 0 -t 0 -t 0; -t 0 0 0 E 0 -t 0...

2 days ago | 0

| accepted

Answered

what is wrong with my script

clear all for loop_index = 1:2 x = input('Input number to convert'); units = input('Input the units to convert from','s...

what is wrong with my script

clear all for loop_index = 1:2 x = input('Input number to convert'); units = input('Input the units to convert from','s...

2 days ago | 1

| accepted

Answered

Any trick to name a variable with decimal number?

No, it is simply not allowed in Matlab. No way, no trick: https://de.mathworks.com/help/matlab/matlab_prog/variable-names.html#...

Any trick to name a variable with decimal number?

No, it is simply not allowed in Matlab. No way, no trick: https://de.mathworks.com/help/matlab/matlab_prog/variable-names.html#...

3 days ago | 0

Answered

PULL OUT A SPECIFIC WORD FROM A LONG STRING

You might want to start reading here: https://de.mathworks.com/help/matlab/matlab_prog/searching-and-replacing.html

PULL OUT A SPECIFIC WORD FROM A LONG STRING

You might want to start reading here: https://de.mathworks.com/help/matlab/matlab_prog/searching-and-replacing.html

3 days ago | 1

| accepted

Answered

How do I create a for loop to extract data from table?

No loop is needed: A = unstack(ReactionTime,'RESPONSE_TIME_ehmi','videostring') since you have invalid names for you video fil...

How do I create a for loop to extract data from table?

No loop is needed: A = unstack(ReactionTime,'RESPONSE_TIME_ehmi','videostring') since you have invalid names for you video fil...

3 days ago | 0

| accepted

Answered

complement of an image

I = fliplr(imread('cameraman.tif')); I1 = triu((I),1); I2 = tril(imcomplement(I)); I_res = fliplr(I1+I2); imshow(I_res) B...

complement of an image

I = fliplr(imread('cameraman.tif')); I1 = triu((I),1); I2 = tril(imcomplement(I)); I_res = fliplr(I1+I2); imshow(I_res) B...

3 days ago | 1

| accepted

Answered

Trapz gives "Second and third argument must either be variables or a variable and a nonnegative integer specifying the number of differentiations."

syms x f_scalar = @(x) 5*x^2+3*x-4; g_scalar = @(x) -4*x^2+6*x+5; f = @(vec) arrayfun(f_scalar,vec); g = @(vec) arrayfun(g_sca...

Trapz gives "Second and third argument must either be variables or a variable and a nonnegative integer specifying the number of differentiations."

syms x f_scalar = @(x) 5*x^2+3*x-4; g_scalar = @(x) -4*x^2+6*x+5; f = @(vec) arrayfun(f_scalar,vec); g = @(vec) arrayfun(g_sca...

3 days ago | 0

| accepted

Answered

Problem with input of ode113

I_1= pi^2; I_2= -2*pi^2; params.tau= 10; g= 0; V_1= -65; V_2= -65; state= [V_1;V_2]; I= [I_1;I_2]; options = odeset('ab...

Problem with input of ode113

I_1= pi^2; I_2= -2*pi^2; params.tau= 10; g= 0; V_1= -65; V_2= -65; state= [V_1;V_2]; I= [I_1;I_2]; options = odeset('ab...

4 days ago | 0

| accepted

Answered

How to define discrete variables in GA (genetic algorithm)

https://de.mathworks.com/matlabcentral/answers/401059-setup-discrete-values-for-decision-variables-in-optimization-problems

How to define discrete variables in GA (genetic algorithm)

https://de.mathworks.com/matlabcentral/answers/401059-setup-discrete-values-for-decision-variables-in-optimization-problems

4 days ago | 0

Answered

Surrogate search with integer parameters

|*intcon*| was introduced to surrogateopt in R2019b. <https://de.mathworks.com/help/gads/release-notes.html>

Surrogate search with integer parameters

|*intcon*| was introduced to surrogateopt in R2019b. <https://de.mathworks.com/help/gads/release-notes.html>

4 days ago | 0

| accepted

Answered

Accessing value in a cell

Edited because of the comments: a = {'1,65,4,5'} b = str2num(a{:}) b(2)

Accessing value in a cell

Edited because of the comments: a = {'1,65,4,5'} b = str2num(a{:}) b(2)

5 days ago | 1

| accepted

Answered

Passing parameters in boundary value problem using BVP4C

See here: <https://de.mathworks.com/help/optim/ug/passing-extra-parameters.html |*passing extra parameters*|>. I suggest to eith...

Passing parameters in boundary value problem using BVP4C

See here: <https://de.mathworks.com/help/optim/ug/passing-extra-parameters.html |*passing extra parameters*|>. I suggest to eith...

5 days ago | 0

Answered

How to extract frames from a .mp4 video?

outputFolder1=('video'); v1=VideoReader('Clock.mp4'); vid1Frames=read(v1); for frame=1:size(vid1Frames,4) outputBaseFileNa...

How to extract frames from a .mp4 video?

outputFolder1=('video'); v1=VideoReader('Clock.mp4'); vid1Frames=read(v1); for frame=1:size(vid1Frames,4) outputBaseFileNa...

5 days ago | 0

Answered

Plot pixels from 2D boolean array

% your array A = randi(2,101)-1; % the result; R=255*ones(101); G=255*(-A+1); B=255*(-A+1); res = cat(3,R,G,B); ...

Plot pixels from 2D boolean array

% your array A = randi(2,101)-1; % the result; R=255*ones(101); G=255*(-A+1); B=255*(-A+1); res = cat(3,R,G,B); ...

5 days ago | 0

| accepted

Answered

Return a value from a table

Quarter = {'Q12019'; 'Q22019'; 'Q32019'; 'Q42019'; 'Q12020'; 'Q22020'; 'Q32020'; 'Q42020'}; QuarterStartDate = ['2019-01-01'; '...

Return a value from a table

Quarter = {'Q12019'; 'Q22019'; 'Q32019'; 'Q42019'; 'Q12020'; 'Q22020'; 'Q32020'; 'Q42020'}; QuarterStartDate = ['2019-01-01'; '...

6 days ago | 1

| accepted

Answered

Inserting vertical and horizontal line in bodeplot

xline and yline should work for this purpose. Both functions were introduced with R2018b. If you use an earlier release, just de...

Inserting vertical and horizontal line in bodeplot

xline and yline should work for this purpose. Both functions were introduced with R2018b. If you use an earlier release, just de...

6 days ago | 1

| accepted

Answered

Solving EOM coupled equations using ode45

syms x(t) y(t) eq(1)=diff(y,t,2)==(3/2)*(9.81*sin(y)-diff(x,t,2)*cos(y)); eq(2)=11*diff(x,t,2)+(1/2)*cos(y)*diff(y,t,2)-(1/2...

Solving EOM coupled equations using ode45

syms x(t) y(t) eq(1)=diff(y,t,2)==(3/2)*(9.81*sin(y)-diff(x,t,2)*cos(y)); eq(2)=11*diff(x,t,2)+(1/2)*cos(y)*diff(y,t,2)-(1/2...

6 days ago | 1

| accepted

Answered

Array indices must be positive integers or logical values. Error in (line 8) mr(t)=mi-((mi-mf)*(t./tb));

I doubt you want t to have only one point. Also no for loop is needed: mi=2290000; mf=130000; tb=165; t=linspace(6.5,165...

Array indices must be positive integers or logical values. Error in (line 8) mr(t)=mi-((mi-mf)*(t./tb));

I doubt you want t to have only one point. Also no for loop is needed: mi=2290000; mf=130000; tb=165; t=linspace(6.5,165...

6 days ago | 1

| accepted

Answered

could anyone help me how to combine data in two columns

Res = [A B]

could anyone help me how to combine data in two columns

Res = [A B]

7 days ago | 0

| accepted