repeat the cycle 10 times for non linear equations

1 visualización (últimos 30 días)
sunitha
sunitha el 27 de En. de 2021
Respondida: Kartik el 11 de Sept. de 2023
i have these two equations . i want to find out the variables N ,J and remaining values are constant. J star is a function of J and N star is a function of N..If i give value No=3000, corresponding values i will get. i wrote the code for this and i got the values.Now i whatever the values i am getting final , i have to give the value that as No and i have to get the N and J values.like this i have to repeat 10 times.how can i write like this can anyone help me ??
example: No=3000, N =2500,J=34
No=2500,N=2000,J=67
like this i have to repeat 10 times
Qo*(1+R)*(No-N)-V*(aJ+X*k*N)/(Kn+N),
sqrt((Lstar^1.76)+5.2*(Nstar-Nstar_min))-(Lstar^0.88)/2.6==jstar^0.88
  2 comentarios
sunitha
sunitha el 28 de En. de 2021
in the reference they didnt use iteratons . They ony solved equations

Iniciar sesión para comentar.

Respuestas (1)

Kartik
Kartik el 11 de Sept. de 2023
Hi,
To repeat the process of finding the values of 'N' and 'J' based on the previous results, you can use a loop in MATLAB. Here's an example code snippet that demonstrates how you can achieve this:
% Constants
Qo = 100; % Example value, replace with your constant
R = 0.05; % Example value, replace with your constant
V = 10; % Example value, replace with your constant
aJ = 0.1; % Example value, replace with your constant
X = 0.2; % Example value, replace with your constant
k = 0.3; % Example value, replace with your constant
Kn = 1000; % Example value, replace with your constant
Nstar_min = 100; % Example value, replace with your constant
% Number of iterations
numIterations = 10;
% Preallocate arrays to store results
No_values = zeros(numIterations, 1);
N_values = zeros(numIterations, 1);
J_values = zeros(numIterations, 1);
% Loop to solve equations and store results
for iter = 1:numIterations
% Assign current value of No
No = 3000; % Example value, replace with your desired values for each iteration
No_values(iter) = No;
% Solve equations for N and J
syms N J
eq1 = Qo*(1+R)*(No-N)-V*(aJ+X*k*N)/(Kn+N) == 0;
eq2 = sqrt((J^1.76)+5.2*(N-Nstar_min))-(J^0.88)/2.6 == 0;
sol = solve(eq1, eq2, N, J);
% Store N and J values
N_values(iter) = double(sol.N);
J_values(iter) = double(sol.J);
end
% Display the results
for iter = 1:numIterations
fprintf('No = %d, N = %d, J = %d\n', No_values(iter), N_values(iter), J_values(iter));
end
In this code, you start with an initial value for 'No' and then use a loop to repeat the process 10 times. In each iteration, the equations are solved using the 'solve' function, and the values of 'N' and 'J' are extracted from the solution. The results are then displayed, and the value of 'No' is updated for the next iteration.
You can modify the constants and initial values according to your specific requirements.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by