Find all possible ordered pairs that satisfy a linear equation
2 次查看(过去 30 天)
显示 更早的评论
I am trying to find all possible combinations of X and Y that satisfy the following linear equation:
f = ((X*25)+(Y*(24))) == 100
The variables should only be evaluated in the following range:
1 ≤ X ≥ 7 and 0.1 ≤ Y ≥ 3 or put another way X = 1:0.01:7 and Y = 0.1:0.01:3
I assume there are multiple simple ways to solve this using either for loops or syms approaches.
0 个评论
回答(1 个)
Star Strider
2021-5-16
The ‘all possible’ criterion would produce infinite solutions. I suspect you would spend the rest of your life calculationg it!
Here is a slightly more limited calculation —
B = 1;
k = 1;
while (B>=0.1) & (B<=7)
X(k,:) = k/10;
B = (100 - X(k,:)*25)/24;
Y(k,:) = B;
k = k+1;
end
Result = table(X,Y)
.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!