Answered

selecting indices in a matrix and setting the rest to zero

A = rand(5,3); idx = [2 4].'; idx_left = setdiff(1:size(A,1),idx) A(idx_left,:) = zeros(numel(idx_left),size(A,2))

selecting indices in a matrix and setting the rest to zero

A = rand(5,3); idx = [2 4].'; idx_left = setdiff(1:size(A,1),idx) A(idx_left,:) = zeros(numel(idx_left),size(A,2))

9 days ago | 0

| accepted

Answered

I am trying to solve current equations of a pv cell using fsolve butit keeps showing error, can someone pls see what the error in my code is?

clc; clear all; Pmpp = 50; %Max Power Vmpp = 17.98; %Vol at Pmax Impp = 2.77; %Current at Pmax Isc= 3; ...

I am trying to solve current equations of a pv cell using fsolve butit keeps showing error, can someone pls see what the error in my code is?

clc; clear all; Pmpp = 50; %Max Power Vmpp = 17.98; %Vol at Pmax Impp = 2.77; %Current at Pmax Isc= 3; ...

9 days ago | 0

| accepted

Answered

Use one function in another

n = 7; a = [3 4 1 2 5 2 1]; A = createMatrix(n, a) period = findPeriod(A) function A = createMatrix(n, a) A = zeros(n);...

Use one function in another

n = 7; a = [3 4 1 2 5 2 1]; A = createMatrix(n, a) period = findPeriod(A) function A = createMatrix(n, a) A = zeros(n);...

9 days ago | 0

| accepted

Answered

Bvp4c 2nd order equation with 2nd and 3rd order boundary conditions

Since you can only impose two boundary conditions for a second-order equation, take the first and the third. They should already...

Bvp4c 2nd order equation with 2nd and 3rd order boundary conditions

Since you can only impose two boundary conditions for a second-order equation, take the first and the third. They should already...

9 days ago | 0

| accepted

Answered

Solve non linear m equations in n unknows with m,n

k = lsqnonlin(F,k0)

Solve non linear m equations in n unknows with m,n

k = lsqnonlin(F,k0)

9 days ago | 0

| accepted

Answered

How can ı solve this difference equation ?

um2 = 0; um1 = 0; u0 = 1.5820; u1 = -0.5820; u2 = 0; xm2 = 0; xm1 = 0; x0 = 1.3679*xm1 - 0.3679*xm2 + 0.3679*um1 + 0.2642...

How can ı solve this difference equation ?

um2 = 0; um1 = 0; u0 = 1.5820; u1 = -0.5820; u2 = 0; xm2 = 0; xm1 = 0; x0 = 1.3679*xm1 - 0.3679*xm2 + 0.3679*um1 + 0.2642...

10 days ago | 0

| accepted

Answered

Variable not saving as a double

You mean t = 0:1:100; x = 0.5*exp(2*sin(t))./(10.5*exp(2*sin(t))); plot(t,x) (which is equal to 0.5/10.5=0.04761... because ...

Variable not saving as a double

You mean t = 0:1:100; x = 0.5*exp(2*sin(t))./(10.5*exp(2*sin(t))); plot(t,x) (which is equal to 0.5/10.5=0.04761... because ...

12 days ago | 0

| accepted

Answered

Constraints on Parameter Estimation

Use lsqlin instead of fitlm.

Constraints on Parameter Estimation

Use lsqlin instead of fitlm.

12 days ago | 0

| accepted

Answered

problem in creating function file using ode45

Be careful with the order of the solution vector Y. It is (y, Dy, x, Dx). You have to supply the vector of initial values "ic" i...

problem in creating function file using ode45

Be careful with the order of the solution vector Y. It is (y, Dy, x, Dx). You have to supply the vector of initial values "ic" i...

12 days ago | 0

| accepted

Answered

How do I plot two different functions on the same plot?

Use hold on plot(...) % plot first graph plot(...) % plot second graph hold off

How do I plot two different functions on the same plot?

Use hold on plot(...) % plot first graph plot(...) % plot second graph hold off

12 days ago | 0

| accepted

Answered

solving series of algebric linear equations using for loop

N = 4; xleft = 1.0; xright = 3.0; x = linspace(xleft,xright,N+1); h = (xright-xleft)/N; A = zeros(N+1); b = zeros(N+1,1); ...

solving series of algebric linear equations using for loop

N = 4; xleft = 1.0; xright = 3.0; x = linspace(xleft,xright,N+1); h = (xright-xleft)/N; A = zeros(N+1); b = zeros(N+1,1); ...

13 days ago | 0

Answered

Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.

You don't define Kb as a global variable in the part of your code where you set it as Kb = physconst('boltzmann'); % 1.38*10^(-...

Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.

You don't define Kb as a global variable in the part of your code where you set it as Kb = physconst('boltzmann'); % 1.38*10^(-...

13 days ago | 0

Answered

Projectile Motion when y0 does not equal 0

Solve y(t) = 0 for t and you'll find tf, the time when the projectile hits the ground.

Projectile Motion when y0 does not equal 0

Solve y(t) = 0 for t and you'll find tf, the time when the projectile hits the ground.

13 days ago | 1

Answered

Matrix "index in position 1 exceeds array bounds (must not exceed 1)"

i=1; X1(i)=0; X2(i)=0; X3(i)=0; error_X1(i)=9999; error_X2(i)=9999; error_X3(i)=9999; instead of i=1; X1=0; X2=0; X3=...

Matrix "index in position 1 exceeds array bounds (must not exceed 1)"

i=1; X1(i)=0; X2(i)=0; X3(i)=0; error_X1(i)=9999; error_X2(i)=9999; error_X3(i)=9999; instead of i=1; X1=0; X2=0; X3=...

13 days ago | 0

Answered

invalid expression error.

B = 0.02; a = 0.1; f = 0.53; phi = 3*pi/4; t = -5:0.05:10; x = B^a*exp (-a*t) .*sin(... 2*pi*f*t+phi); xu = x...

invalid expression error.

B = 0.02; a = 0.1; f = 0.53; phi = 3*pi/4; t = -5:0.05:10; x = B^a*exp (-a*t) .*sin(... 2*pi*f*t+phi); xu = x...

13 days ago | 1

| accepted

Answered

please help i keep getting erro

samsonwork() function sol=samsonwork global Br Sc delta P K R n epsilon %x=linspace(-1,1,11); r=0:0.01:3; Br=1;Sc=0.4;n=3;d...

please help i keep getting erro

samsonwork() function sol=samsonwork global Br Sc delta P K R n epsilon %x=linspace(-1,1,11); r=0:0.01:3; Br=1;Sc=0.4;n=3;d...

13 days ago | 1

| accepted

Answered

fmincon: proble defining the function

f = @definefunction; instead of f=definefunction(x); And you cannot use random inputs on each call - thus comp1 = double(ra...

fmincon: proble defining the function

f = @definefunction; instead of f=definefunction(x); And you cannot use random inputs on each call - thus comp1 = double(ra...

14 days ago | 0

| accepted

Answered

Finding linear combination of two vectors such as every element is positive

n = 5; v1 = -10 + rand(1,n)*20 v2 = -20 + rand(1,n)*40 % If there is a solution x for which A*x > zeros(size(A,1),1), then th...

Finding linear combination of two vectors such as every element is positive

n = 5; v1 = -10 + rand(1,n)*20 v2 = -20 + rand(1,n)*40 % If there is a solution x for which A*x > zeros(size(A,1),1), then th...

14 days ago | 1

Answered

User defined function within ode45

Symbolic functions like the one you get if you use the "piecewise" command are not allowed with ODE45. Either define the right-...

User defined function within ode45

Symbolic functions like the one you get if you use the "piecewise" command are not allowed with ODE45. Either define the right-...

14 days ago | 0

Answered

How can I do a Monte Carlo simulation for 1000 runs on this operation?

Maybe you mean: % A = T(:,1); %Column vector A = [71.213; 74.499; 79.175; 54.163; 83.008; 52.615]; B = length(A); %size of c...

How can I do a Monte Carlo simulation for 1000 runs on this operation?

Maybe you mean: % A = T(:,1); %Column vector A = [71.213; 74.499; 79.175; 54.163; 83.008; 52.615]; B = length(A); %size of c...

14 days ago | 0

| accepted

Answered

Can someone help me to correct the code for this problem using ode45 solver?

This is a boundary value problem, not an initial value problem since conditions on f and theta are given on both ends of the int...

Can someone help me to correct the code for this problem using ode45 solver?

This is a boundary value problem, not an initial value problem since conditions on f and theta are given on both ends of the int...

14 days ago | 1

Answered

i dont know why there is no anwser about this 'solve'

Three equations need three unknowns, not only one. clc; close all; clear; a1=20; b1=20; k1=sqrt((a1+10)^2+b1^2)-sqrt((a1-...

i dont know why there is no anwser about this 'solve'

Three equations need three unknowns, not only one. clc; close all; clear; a1=20; b1=20; k1=sqrt((a1+10)^2+b1^2)-sqrt((a1-...

15 days ago | 0

Answered

Numerical integration of a nested integral; limits of inner integral depend on the outer integration variable

I'm not sure your integral exists ... Bessel_integrand = @(x) x .* besselj(0,x); Integrand_B = @(a) integral(Bessel_integrand,...

Numerical integration of a nested integral; limits of inner integral depend on the outer integration variable

I'm not sure your integral exists ... Bessel_integrand = @(x) x .* besselj(0,x); Integrand_B = @(a) integral(Bessel_integrand,...

15 days ago | 0

Answered

Error in plotting a function, left and right side with diferent dimensions

Most probably, vet_servido(j) = - (1/2) * log(1- x_exp(j)); instead of vet_servido(j) = - (1/2) * log(1- x_exp);

Error in plotting a function, left and right side with diferent dimensions

Most probably, vet_servido(j) = - (1/2) * log(1- x_exp(j)); instead of vet_servido(j) = - (1/2) * log(1- x_exp);

16 days ago | 0

| accepted

Answered

Left division with partially known coefficient

It's a nonlinear fitting problem - backslash doesn't suffice here. I set p = 1/(d*K) . If you like, you can retransform the res...

Left division with partially known coefficient

It's a nonlinear fitting problem - backslash doesn't suffice here. I set p = 1/(d*K) . If you like, you can retransform the res...

16 days ago | 0

| accepted

Answered

Why do I get "Array indices must be positive integers or logical values"?

Ta = 504; y = 1.4; Ra = 1716; M = .1:.1:5; for i = 1:numel(M) u(i) = M(i)*sqrt(y*Ra*Ta); end plot(M,u) or simply Ta...

Why do I get "Array indices must be positive integers or logical values"?

Ta = 504; y = 1.4; Ra = 1716; M = .1:.1:5; for i = 1:numel(M) u(i) = M(i)*sqrt(y*Ra*Ta); end plot(M,u) or simply Ta...

17 days ago | 0

Answered

numerical integration theorem of residues

You can define the function to be integrated in a function - you don't need to use handles. In this function, you can perform a...

numerical integration theorem of residues

You can define the function to be integrated in a function - you don't need to use handles. In this function, you can perform a...

17 days ago | 0

| accepted

Answered

Integral of matrix determinant

f=@(x)det([1,x;0,2]); integral(f,0,1,'ArrayValued',true)

Integral of matrix determinant

f=@(x)det([1,x;0,2]); integral(f,0,1,'ArrayValued',true)

17 days ago | 0

| accepted

Answered

custom logarithmic fit with three coefficients

It doesn't make sense to use three fitting parameters for the function type you supply. a + b*log(c*x) = a + b*log(c) + b*log(x...

custom logarithmic fit with three coefficients

It doesn't make sense to use three fitting parameters for the function type you supply. a + b*log(c*x) = a + b*log(c) + b*log(x...

17 days ago | 0

| accepted

Answered

lsqcurvefit for multiple variables optimization

We need your "YL_function" to see what's happening. I wonder whether your transformation is correct. I would have thought y_r...

lsqcurvefit for multiple variables optimization

We need your "YL_function" to see what's happening. I wonder whether your transformation is correct. I would have thought y_r...

17 days ago | 0

| accepted