Answered

Matlab problem: How to calculate a rough, approximate, derivative vector by using the following formula?

x=-10:10; y=x.^2; Yprimenum=diff(y)./diff(x)

Matlab problem: How to calculate a rough, approximate, derivative vector by using the following formula?

x=-10:10; y=x.^2; Yprimenum=diff(y)./diff(x)

9 years ago | 0

| accepted

Answered

Making each element of a row vector equal to zero

You can create a new vector with all zeros by typing the command: new=zeros(1,100) or by using a for loop: for I=1:...

Making each element of a row vector equal to zero

You can create a new vector with all zeros by typing the command: new=zeros(1,100) or by using a for loop: for I=1:...

9 years ago | 0

Answered

detect consecutive duplicates in a structure

A(1).a=1 A(2).a=1 A(3).a=3 A(1).b=true A(2).b=true A(3).b=false for ii=2:3 ttest(ii-1)=A(ii).a==A...

detect consecutive duplicates in a structure

A(1).a=1 A(2).a=1 A(3).a=3 A(1).b=true A(2).b=true A(3).b=false for ii=2:3 ttest(ii-1)=A(ii).a==A...

9 years ago | 0

Answered

Different length array comparison and replacements

% data A=[445; 874]; B= [265; 446; 744; 872; 875]; % engine AA=A(:,ones(1,size(...

Different length array comparison and replacements

% data A=[445; 874]; B= [265; 446; 744; 872; 875]; % engine AA=A(:,ones(1,size(...

9 years ago | 0

Answered

Extra term in "min" function in while loop

The extra ,DC1(1,j) bit is the next command. You can erase the initial comma and press enter to get it in the next lin...

Extra term in "min" function in while loop

The extra ,DC1(1,j) bit is the next command. You can erase the initial comma and press enter to get it in the next lin...

9 years ago | 1

Answered

Finding x & y-values that maximize an expression!!!!

The expression for J does not have any maxima. This can be seen easily by geometric interpretation of the formula. J can be mini...

Finding x & y-values that maximize an expression!!!!

The expression for J does not have any maxima. This can be seen easily by geometric interpretation of the formula. J can be mini...

9 years ago | 0

Answered

fft normalization and parseval

In the following code: var1=128; h=complex(randi([-1 1],var1,1),randi([-1 1],var1,1)); h=h/std(h); % no h is normaliz...

fft normalization and parseval

In the following code: var1=128; h=complex(randi([-1 1],var1,1),randi([-1 1],var1,1)); h=h/std(h); % no h is normaliz...

9 years ago | 0

Answered

HOW TO ACCESS THE FOLLOWING ELEMENTS FROM THE GIVEN ARRAY

a=[ 0 0 0.3013 1.1305; 1.0000 2.0000 0.7390 0.4223; 3.0000 2.0000 1.1305 ...

HOW TO ACCESS THE FOLLOWING ELEMENTS FROM THE GIVEN ARRAY

a=[ 0 0 0.3013 1.1305; 1.0000 2.0000 0.7390 0.4223; 3.0000 2.0000 1.1305 ...

9 years ago | 0

Answered

Regarding Genetic Algorithm Optimization- How to stop GA tool after each generation

t=0.2; % or any other reasonable time value while exist('filename.extension','file')==2 pause(t) end

Regarding Genetic Algorithm Optimization- How to stop GA tool after each generation

t=0.2; % or any other reasonable time value while exist('filename.extension','file')==2 pause(t) end

9 years ago | 0

Answered

problem with if test to test the increment in time

T = 1e-4; h = T/100; n = 1000;%par exemple Ts = 0:T:n*T; j = 1; for t =0:h:n*T if ismembc(t,Ts) ...

problem with if test to test the increment in time

T = 1e-4; h = T/100; n = 1000;%par exemple Ts = 0:T:n*T; j = 1; for t =0:h:n*T if ismembc(t,Ts) ...

9 years ago | 0

Answered

interpolate data points problem

At least one entry in Y is NaN (Not-A-Number). To find it, type in the command window: find(isnan(Y)) You should check ...

interpolate data points problem

At least one entry in Y is NaN (Not-A-Number). To find it, type in the command window: find(isnan(Y)) You should check ...

9 years ago | 0

| accepted

Answered

How to reduce execution time? "If" and "ismember" functions

To make ismember function faster, replace it with either *ismembc* or *ismembc2* functions. *ismembc* returns an array of logica...

How to reduce execution time? "If" and "ismember" functions

To make ismember function faster, replace it with either *ismembc* or *ismembc2* functions. *ismembc* returns an array of logica...

9 years ago | 0

Answered

How to find the indices of element occuring once in a vector?

A=[1 1 -1 0 0 0 1 0 1 1]; [~,c]=histc(A,unique(A)); out=find(c==1);

How to find the indices of element occuring once in a vector?

A=[1 1 -1 0 0 0 1 0 1 1]; [~,c]=histc(A,unique(A)); out=find(c==1);

9 years ago | 0

Answered

How to find the indices of element occuring once in a vector?

A=[1 1 0 -1 0 0 1 0 1 1]; [~,c]=histc(A,unique(A)); out=A(c==1);

How to find the indices of element occuring once in a vector?

A=[1 1 0 -1 0 0 1 0 1 1]; [~,c]=histc(A,unique(A)); out=A(c==1);

9 years ago | 3

Answered

code of euler's method

A simple application of Euler method: Define the function: function E=euler(f,a,b,ya,M) h=(b-a)/M; Y=zeros(1,M+1);...

code of euler's method

A simple application of Euler method: Define the function: function E=euler(f,a,b,ya,M) h=(b-a)/M; Y=zeros(1,M+1);...

9 years ago | 1

| accepted

Answered

To sum functions which have two unknowns and finding the min values of these unknowns

See if this works: F=zeros(200,1); xy=zeros(200,2); BS=rand(4,2); r=rand(200); for ti=1:200 for m=1:4 ...

To sum functions which have two unknowns and finding the min values of these unknowns

See if this works: F=zeros(200,1); xy=zeros(200,2); BS=rand(4,2); r=rand(200); for ti=1:200 for m=1:4 ...

9 years ago | 0

Answered

How to generate a total random 6 by 6 Latin Square?

Look at the following: http://www.mathworks.com/matlabcentral/fileexchange/12315-latsq/content/latsq.m Hope this helps!

How to generate a total random 6 by 6 Latin Square?

Look at the following: http://www.mathworks.com/matlabcentral/fileexchange/12315-latsq/content/latsq.m Hope this helps!

9 years ago | 0

Answered

How to make an anonymous function whose variable is itself a function of another variable?

z = @(phi) cos(phi).^2 + 4*sin(phi).^2 phi = @(x) x.^3 + 4*x.^2 + x +3 z(phi(3))

How to make an anonymous function whose variable is itself a function of another variable?

z = @(phi) cos(phi).^2 + 4*sin(phi).^2 phi = @(x) x.^3 + 4*x.^2 + x +3 z(phi(3))

9 years ago | 1

| accepted

Answered

how to make output a for loop subtract sequentially a data set below it to give sum of differences

Do you want this: b=2; c=1; d=1; n=4; Y=b*c*d*n; X = [10 13 15 12 17 23 26 19]; f = [1 4 8 10 12 16 18 20];...

how to make output a for loop subtract sequentially a data set below it to give sum of differences

Do you want this: b=2; c=1; d=1; n=4; Y=b*c*d*n; X = [10 13 15 12 17 23 26 19]; f = [1 4 8 10 12 16 18 20];...

9 years ago | 0

| accepted

Answered

Breaking a function into components?

Make a function named myfunc as follows: %---------------------- function out=myfunc(a,vec) out=a.*vec; end %----...

Breaking a function into components?

Make a function named myfunc as follows: %---------------------- function out=myfunc(a,vec) out=a.*vec; end %----...

9 years ago | 0

Answered

How to generate an array alternating the values of two others?

A = [1 2 3 4 5 6]; B = [10 20 30 40 50 60 70 80 90 100 110 120 130 140 150]; M1=[A,A,A(1:3)]; M2=B; M=[M1;M2]; Se...

How to generate an array alternating the values of two others?

A = [1 2 3 4 5 6]; B = [10 20 30 40 50 60 70 80 90 100 110 120 130 140 150]; M1=[A,A,A(1:3)]; M2=B; M=[M1;M2]; Se...

9 years ago | 1

Answered

fminunc stopped because it exceeded the function evaluation limit, options.MaxFunEvals = 100 (the default value).

Define the objective function by setting its output with the opposite sign as follows: function F=fun(x) F=-0.2662*x.^6+...

fminunc stopped because it exceeded the function evaluation limit, options.MaxFunEvals = 100 (the default value).

Define the objective function by setting its output with the opposite sign as follows: function F=fun(x) F=-0.2662*x.^6+...

9 years ago | 0

| accepted

Answered

hi am working on a code for gaussian elimination

The correct function is: function [x,U]=gausselim(A,b) % function to perform gauss eliminination %FORWARD ELI...

hi am working on a code for gaussian elimination

The correct function is: function [x,U]=gausselim(A,b) % function to perform gauss eliminination %FORWARD ELI...

9 years ago | 1

| accepted

Answered

How can I solve system of the matrix differential equation within MATLAB?

eqn = 'D2y - A*Dy - B*y = C'; inits2 = 'y(0)=a, Dy(0)=b'; y=dsolve(eqn,inits2,'x') where a and b are the initial or bou...

How can I solve system of the matrix differential equation within MATLAB?

eqn = 'D2y - A*Dy - B*y = C'; inits2 = 'y(0)=a, Dy(0)=b'; y=dsolve(eqn,inits2,'x') where a and b are the initial or bou...

9 years ago | 0

Answered

trying to delete 2 cells of Nans, NOT To delete the row

At least one of the values of JT_S_TN([13,14,15,34,35,36,55,56,57,76,77,78],2) must be equal to 2 and at least one of the ...

trying to delete 2 cells of Nans, NOT To delete the row

At least one of the values of JT_S_TN([13,14,15,34,35,36,55,56,57,76,77,78],2) must be equal to 2 and at least one of the ...

9 years ago | 0

Answered

matlab sovle newton raphson method

Look for the following Newton-Raphson solver in the File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/44315-...

matlab sovle newton raphson method

Look for the following Newton-Raphson solver in the File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/44315-...

9 years ago | 0

Answered

simpsons rule in matlab

a= Initial point of integration interval b= Last point of integration interval n= number of sub-intervals (panels) of in...

simpsons rule in matlab

a= Initial point of integration interval b= Last point of integration interval n= number of sub-intervals (panels) of in...

9 years ago | 0

Answered

a problem with for loop and indexinf

A={Array_1;Array_2;Array_3;Array_4;Array_5;Array_6;Array_7;Array_8;Array_9;Array_10}; for k=1:10 AR{k}=exp(A{k})+A{k...

a problem with for loop and indexinf

A={Array_1;Array_2;Array_3;Array_4;Array_5;Array_6;Array_7;Array_8;Array_9;Array_10}; for k=1:10 AR{k}=exp(A{k})+A{k...

9 years ago | 0

Answered

delete a NAN but leave a zero instead to be later taken out

A=[NaN 0; 1 3; 1 3; 1 3; 2 4; 2 4; 2 4; 3 1; 3 1; 3 1; 4 2; 4 2; 4 2; NaN 0; 5 4]; sizA=size(A,1); A=A(:); ...

delete a NAN but leave a zero instead to be later taken out

A=[NaN 0; 1 3; 1 3; 1 3; 2 4; 2 4; 2 4; 3 1; 3 1; 3 1; 4 2; 4 2; 4 2; NaN 0; 5 4]; sizA=size(A,1); A=A(:); ...

9 years ago | 0

| accepted

Answered

How to copy a sub-matrix/vector along diagonal of a larger matrix with varying number of sub-matrices?

e = ones(n,1); A = full(spdiags([e 2*e 3*e], 0:2, n, n+2)) A = full(spdiags(A, 0:5, n, n+5)) A = full(spdiags(A, 0:8, n...

How to copy a sub-matrix/vector along diagonal of a larger matrix with varying number of sub-matrices?

e = ones(n,1); A = full(spdiags([e 2*e 3*e], 0:2, n, n+2)) A = full(spdiags(A, 0:5, n, n+5)) A = full(spdiags(A, 0:8, n...

10 years ago | 0