You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
how to find unknowns for series of input values?
3 views (last 30 days)
Show older comments
Engineer Batoor khan mummand
on 15 Oct 2020
Commented: Engineer Batoor khan mummand
on 22 Oct 2020
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.
Accepted Answer
Alan Stevens
on 15 Oct 2020
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 Comments
Engineer Batoor khan mummand
on 15 Oct 2020
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
on 15 Oct 2020
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
on 15 Oct 2020
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
on 15 Oct 2020
Edited: Engineer Batoor khan mummand
on 15 Oct 2020
thanks dear:
i edited the question , i hope you got my point.
thanks
Alan Stevens
on 15 Oct 2020
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
on 16 Oct 2020
done....
thank you so much from your help and support.
thanks
Engineer Batoor khan mummand
on 16 Oct 2020
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
on 16 Oct 2020
I hope the following explains it (you'll need to know about matrix multiplication to understand it):
Engineer Batoor khan mummand
on 16 Oct 2020
okkkkkkk.......
thank you so much from your help and support.
Engineer Batoor khan mummand
on 16 Oct 2020
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
on 16 Oct 2020
Edited: Alan Stevens
on 16 Oct 2020
(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
on 16 Oct 2020
Edited: Alan Stevens
on 16 Oct 2020
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
on 16 Oct 2020
it is done ,thank you so much from your helping....
thanks once again dear Alan Stevens .
Alan Stevens
on 16 Oct 2020
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
on 19 Oct 2020
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
on 19 Oct 2020
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
on 19 Oct 2020
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
on 19 Oct 2020
Edited: Engineer Batoor khan mummand
on 19 Oct 2020
thanks from your reply dear .
Alan Stevens
on 19 Oct 2020
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
on 19 Oct 2020
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
on 19 Oct 2020
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
on 19 Oct 2020
Edited: Engineer Batoor khan mummand
on 19 Oct 2020
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
on 19 Oct 2020
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
on 21 Oct 2020
thanks you so much dear from your supprt and help my problem is solved .
once agian thank you
Engineer Batoor khan mummand
on 22 Oct 2020
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
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)