how to find unknowns for series of input values?
2 次查看(过去 30 天)
显示 更早的评论
Hi all:
how to find x and y for series of values of m and n.
2xm-3yn=100
x+y=50
where n and m are constants such that
m=[2 5 7 10]
n=[4 20 3 4]
i want to find x and y for all m and n values such taht x and y for the first values of m and n(m=2 & n=4).
again x and y for second values of m and n(m=5 & n=20) and so on...
thanks from all of you.
采纳的回答
Alan Stevens
2020-10-15
Do you mean you want to find the values of x and y that satisfy 2*x*2 - 3*y*4 = 100? If so you should be aware that there are an infinite number of solutions!
Or do you mean you want to find the values of x and y that are a best fit to all 4 sets of equations simultaneousy?
32 个评论
Engineer Batoor khan mummand
2020-10-15
thank from your reply:
i want to find values of x and y under n and m condition .
i mean i want to find x and y for first values of m and n second i wnt to find values of x and y by using second values of m and n... up to the last values of m and n .
thanks
Engineer Batoor khan mummand
2020-10-15
find :
x and y whre m=2 and n=4
x and y whre m=5and n=20
x and y whre m=7 and n=3
x and y whre m=10 and n=4
thanks
Alan Stevens
2020-10-15
As I said, there are an infinite number of solutions. Take the first one for example:
4x - 12y = 100
y = 1, x = 28
y = 2, x = 31
y = 3, x = 34
...etc.
Engineer Batoor khan mummand
2020-10-15
编辑:Engineer Batoor khan mummand
2020-10-15
thanks dear:
i edited the question , i hope you got my point.
thanks
Alan Stevens
2020-10-15
Ok.
m=[2 5 7 10];
n=[4 20 3 4];
for i = 1:4
M = [2*m(i) -3*n(i); 1 1];
V = [100; 50];
xy = M\V;
x(i) = xy(1);
y(i) = xy(2);
end
disp(x)
disp(y)
Engineer Batoor khan mummand
2020-10-16
hi Alan Stevens:
M = [2*m(i) -3*n(i); 1 1]; if you give me some information about [;1 1] you have given in code.
thanks
Alan Stevens
2020-10-16
I hope the following explains it (you'll need to know about matrix multiplication to understand it):
Engineer Batoor khan mummand
2020-10-16
okkkkkkk.......
thank you so much from your help and support.
Engineer Batoor khan mummand
2020-10-16
hi Alan Stevens :
i want to solve this problem by your method but it give me some problems
it is same to same problem like you have solved in last comments...
syms Tg T1 T2 Tb Tc Tw2
I=[116 207 414 611 909 1009 951 909 805 615 311 120];
Ta=[29 30 31 32 33 34 35 37 36 35 34 33];
m=100;
n=40;
k=4180;
E1=I+k*I+k(Tc-T2)==4*k*(T2-Tb);
E2=m.*I+4.*I+(T2-Tb)==m*(Tb-Tw1);
E3=2*m.*I+(T1-Tc)==(Tc-Ta)))*I+(Tc-T2);
E4=3*n*I+(Tg-T1)==(T1-Tc);
E5=3*I==(Tg-Ta)+(Tg-T1);
E6=(Tb-Tw1)==(40*k*m*(Tw2-Tw1));
sol = solve([E1, E2, E3,E4,E5,E6],[T2,Tb,T1,Tc,Tg,Tw2]);
T2 = sol.T2
Tb = sol.Tb
Tg = sol.Tg
T1 = sol.T1
Tc = sol.Tc
Note: to find all 6 unknowns from 6 equations by using values of I and Ta....
i will be very thankful to help me in this problem.
thanks
Alan Stevens
2020-10-16
编辑:Alan Stevens
2020-10-16
(1) You have Tw1 in your equations, but haven't specified it.
(2) To use the matrix method you first need to rewrite the equations so that the unknowns are collected on the left-hand side and the known values are on the right hand side. For example, E1 would need to be rewritten as
5*k*T2 - 4*k*Tb - k*Tc + 0*Tg + 0*T1 + 0*Tw2 = I*(1+k)
The coefficients of the first row of matrix M would then be [5*k, -4*k, -k, 0, 0, 0] and the first entry in vector V would be I*(1+k)
The other equations need to be arranged similarly, ensuring the unknowns (T2, Tb etc) are arranged in the same order in every row.
Alan Stevens
2020-10-16
编辑:Alan Stevens
2020-10-16
Like the following. However, you need to check your equations carefully as well as checking that I've rearranged them correctly:
I=[116 207 414 611 909 1009 951 909 805 615 311 120];
Ta=[29 30 31 32 33 34 35 37 36 35 34 33];
Tw1 = 20;
m=100;
n=40;
k=4180;
%E1=I+k*I+k(Tc-T2)==4*k*(T2-Tb);
%E2=m.*I+4.*I+(T2-Tb)==m*(Tb-Tw1);
%E3=2*m.*I+(T1-Tc)==(Tc-Ta)))*I+(Tc-T2);
%E4=3*n*I+(Tg-T1)==(T1-Tc);
%E5=3*I==(Tg-Ta)+(Tg-T1);
%E6=(Tb-Tw1)==(40*k*m*(Tw2-Tw1));
% Rewrite as follows:
% 5*k*T2 -4*k*Tb -k*Tc + 0*T1 + 0*Tg + 0*Tw2 = I*(1+k)
% T2 -(1+m)*Tb + 0*Tc + 0*T1 + 0*Tg + 0*Tw2 = -m*Tw1 - (4+m)*I
% T2 + 0*Tb -(2+I)*Tc + T1 + 0*Tg + 0*Tw2 = -(Ta+2*m)*I
% 0*T2 + 0*Tb - Tc + 2*T1 - Tg + 0*Tw2 = 3*n*I
% 0*T2 + 0*Tb +0*Tc - T1 + 2*Tg + 0*Tw2 = 3*I
% 0*T2 + Tb + 0*Tc + 0*T1 + 0*Tg - 40*k*m*Tw2 = (1+40*k*m)*Tw1
T = zeros(6,numel(I));
for i = 1:numel(I)
M = [5*k, -4*k, -k, 0, 0, 0;
1, -(1+m), 0, 0, 0, 0;
1, 0, -(2+I(i)), 1, 0, 0;
0, 0, -1, 2, -1, 0;
0, 0, 0, -1, 2, 0;
0, 1, 0, 0, 0, -40*k*m];
V = [(1+k)*I(i);
-m*Tw1-(4+m)*I(i);
-(Ta(i)+2*m)*I(i);
3*n*I(i);
3*I(i);
(1+40*k*m)*Tw1];
T(:,i) = M\V;
end
T2 = T(1,:);
Tb = T(2,:);
Tc = T(3,:);
T1 = T(4,:);
Tg = T(5,:);
Tw2 = T(6,:);
disp(T)
Engineer Batoor khan mummand
2020-10-16
it is done ,thank you so much from your helping....
thanks once again dear Alan Stevens .
Alan Stevens
2020-10-16
Note; I have edited the previous coding. The expression for T2 is now
T2 = T(1,:);
not
T2 = T(:,1);
Similarly for Tb, Tc etc.
Engineer Batoor khan mummand
2020-10-19
hi Alan Stevens:
i hop you will be fine and doing well...
i need so help dear in above problem if i say i want to find Tw(i+1) where i=1 Wso when we have Tw1=20;
for each I and Ta i want to find Tw(i+1)...
thanks
Engineer Batoor khan mummand
2020-10-19
problem is same just i want Tw(i+1) such that :
i=1 Twi=Tw1=20;
for first I Ta we will find Tw(i+1)=Tw2?
for second ittration we havw i=2 so Tw(i)=Tw2
Tw(i+1)=Tw(2+1)=Tw3
and so on
Alan Stevens
2020-10-19
I don't really understand what you are asking. You need to set out the equations you are trying to solve in mathematical form, not computer language, for me to stand a chance of understanding.
Engineer Batoor khan mummand
2020-10-19
编辑:Engineer Batoor khan mummand
2020-10-19
thanks from your reply dear .
Alan Stevens
2020-10-19
Hmm. A couple of the equations are different from the ones you posted originally. In particular E6 contains Ti on the LHS. This means you have 7 unknowns, namely Tc T2 Tb Tw T1 Tg and Ti, but only 6 equations! You need another (independent) equation.
What is the physical system these equations represent?
Engineer Batoor khan mummand
2020-10-19
Thanks from u r reply dear ... Twi will be come Tw1 for first iteration when i=1,from this we will find Tw(i+1)=Tw2 For next iteration when i=2 than Twi will become Tw2 which we have already found in iteration one we will find Tw3... Thanks
Alan Stevens
2020-10-19
I wasn't referring to Tw(i+1) as the extra T, but Ti, which appears on the left-hand side of equation E6.
Engineer Batoor khan mummand
2020-10-19
编辑:Engineer Batoor khan mummand
2020-10-19
Sorry dear in equation 6 we have (Tb-Twi) and another mistakes which in equation 1 and that is 4k(T2-Tb). Thanks
Alan Stevens
2020-10-19
Well, the following does the calculation, but the Tw values stay constant!
I=[116 207 414 611 909 1009 951 909 805 615 311 120];
Ta=[29 30 31 32 33 34 35 37 36 35 34 33];
Tw1 = 20;
m=100;
n=40;
k=4180;
T = zeros(6,numel(I));
Tw = Tw1;
for i = 1:numel(I)
M = [5*k, -4*k, -k, 0, 0, 0;
1, -(1+m), 0, 0, 0, 0;
1, 0, -(2+I(i)), 1, 0, 0;
0, 0, -1, 2, -1, 0;
0, 0, 0, -1, 2, 0;
0, 1, 0, 0, 0, -40*k*m];
V = [(1+k)*I(i);
-m*Tw-(4+m)*I(i);
-(Ta(i)+2*m)*I(i);
3*n*I(i);
3*I(i);
(1-40*k*m)*Tw];
T(:,i) = M\V;
Tw = T(6,i);
end
T2 = T(1,:);
Tb = T(2,:);
Tc = T(3,:);
T1 = T(4,:);
Tg = T(5,:);
Tw = T(6,:);
disp(T)
Engineer Batoor khan mummand
2020-10-21
thanks you so much dear from your supprt and help my problem is solved .
once agian thank you
Engineer Batoor khan mummand
2020-10-22
hi dear:
i want to import average of each day from attached excl file but average of those solar radiation which is greather from 200 i mean ignoring all solar radiation of each day whic is less than 200.
i will be very thankful dear .
thanks
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)