Solving Equation (Updated!)

1 visualizzazione (ultimi 30 giorni)
onsagerian
onsagerian il 3 Set 2018
Modificato: onsagerian il 6 Set 2018
Hello,
I already posted the similar question and someone answered it. However, I've deleted what I posted because I found serious problems in my code. I apologize to the person who answered to my question. Now, the following code I've constructed only gives an error. For your information, I used "arrays" instead of single variables for the purpose of plotting later on. I've included the error message I had. Would you help me to address the problem?
format long e
theta=0.01;
n=1:1:20;
m=1:1:10;
x=zeros(length(n),length(m));
gamma_REA=zeros(1,length(m));
equation1=zeros(length(n),length(m));
equation2=zeros(length(n),length(m));
equation=zeros(length(n),length(m));
gamma_REA(1)=10.0;
for i=1:1:length(n)
for j=1:1:length(m)
equation1(i,j)=1+[x(i,j)/(1+x(i,j))]^n(i).*(gamma_REA(j)-1);
equation2(i,j)=1+[x(i,j)/(theta+x(i,j))]^n(i).*(gamma_REA(j)-1);
equation(i,j)=theta*equation1(i,j)./equation2(i,j)-[(theta+x(i,j))/(1+x(i,j))].^(n(i)+1)==0;
sol=vpasolve(equation,x(i,j));
fprintf('%d %.10e %.10e\n',i,gamma_REA(j), min(sol(sol>0.0)));
gamma_REA(j+1)=gamma_REA(j)*10.0;
end
gamma_REA(1)=10.0;
end
See the error message:
Undefined function 'vpasolve' for input arguments of type 'double'.
Error in error_fraction4_test (line 67) sol=vpasolve(equation,x(i,j));

Risposte (1)

Naman Chaturvedi
Naman Chaturvedi il 6 Set 2018
Hello,
You didn't use the 'vpasolve' function correctly. The first argument of the function 'vpasolve' should be the equation and the second the variable for which you want the equation to be solved. I maybe able to help you better if you could provide me the intent of this code. Also, consider reading this document on vpasolve.
  1 Commento
onsagerian
onsagerian il 6 Set 2018
Modificato: onsagerian il 6 Set 2018
Hello,
Thank you for your comment.
The code was designed to solve the equation, giving each numerical value depending on the variables i and j. This part corresponds to "sol=vpasolve(equation,x(i,j))".
In particular, I am interested in fining out solutions satisfying the condition, the minimum values among positive solutions (min(sol(sol>0.0))).
I would appreciate if you would help me.

Accedi per commentare.

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by