MATLAB Answers

Exact data from for loop plot with multiple lines

조회 수: 18(최근 30일)
Tobias Hang
Tobias Hang 10 Dec 2020
답변: Raunak Gupta 17 Dec 2020
Hey guys, sorry my English is unclear.
I'm trying to exact data points from my for loop functions or that corespond with my for loop value.
So I have 2 for loops, 1 is to solve the stoichiometry from my eqn.
Second is running COx_Emission function for each Hy_1 values from (3.1 to 4.0) at 0.1 increment, then running another for loop for Phi value from (0.5 to 1.5 ) for each of the Hy_1 value.
So basically run function F(x,y) for X from(3:0.1:4) , then again with Y from (.5 : .1 : 1.5 ).
Is there a way that I could exact data point from the figure at a certain X location. At the same time show me to correspond Hy_1 & Phi value?
for Hy_1 = 1:0.1:4; % CH(x) combustion
syms a b c d % systtem of eqn to solve for Stoichiometry
e1 = a == b+(c/2);
e2 = b == 1;
e3 = c == (Hy_1)/2;
e4 = d == 3.76*a;
[A,B] = equationsToMatrix([e1, e2, e3, e4], [a, b, c, d]);
X = linsolve(A,B);
t = num2cell(X);
[a,b,c,d] = deal(t{:}); % assign solved unknown to new variable
n_f = 1;
n_o2 = a;
xf = n_f*(1)/(2*(a+3.76*2));
end
hold on
for Hy_1 = 3:0.1:4;
for Phi = 0.5 :.1:1.5;
n_f = 1;
n_02 = a;
xf = n_f*(12+Hy_1)/(2*(32+3.76*28));
TA = T_flame_ad(Cx,Hy_1,Phi);
mr = COx_Emissions(Cx,Hy_1,TA,n_f,n_o2,xf,P);
plot (mr','LineWidth',2);
end
end

답변(1개)

Raunak Gupta
Raunak Gupta 17 Dec 2020
Hi,
I understand that your data is having two independent variables Hy_1 and Phi. Also, you want to plot a function F(x,y) which depends on those two variables. In my opinion lines might not be the best way to visualize the relationship. You can use surf to plot the values F(x,y) in terms of x and y.
As for the second part, if you want to get value of F(x,y) given an intermediate X which does not lies in 3:0.1:4 and 0.5:0.1:1.5 , You can fit a function to the surface using fit and then can get the value of F(x,y) for any intermediate x and y value in range of x and y.

Community Treasure Hunt

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

Start Hunting!

Translated by