Need help with solving equations

2 ビュー (過去 30 日間)
Astro
Astro 2017 年 3 月 13 日
編集済み: Astro 2017 年 3 月 14 日
Say I have a set of equation: x = 2a+1b and y = a-30b, and I want to solve for 'a' and 'b' with x = constant and y = [0:1:10]. Is there a way to go about this without having to solve for 'a' and 'b' as functions of y? I've tried using solve(,) but it only works if x and y are defined first.
Thanks!

採用された回答

Akira Agata
Akira Agata 2017 年 3 月 13 日
How about the following code. This code plots 'a' and 'b' as a function of 'y' where 'x' = 1 (constant).
A = [2 1;1 -30];
xy = [ones(1,11); 0:1:10];
ab = zeros(size(xy));
for kk = 1:11
ab(:,kk) = inv(A)*xy(:,kk)
end
figure
plot(xy(2,:),ab(1,:),xy(2,:),ab(2,:))
title('a,b as a function of y (where x = 1)')
xlabel('y')
ylabel('a, b')
legend({'a','b'})
  1 件のコメント
Astro
Astro 2017 年 3 月 14 日
編集済み: Astro 2017 年 3 月 14 日
Sorry for my late response. It took me a while to understand your code(I'm fairly new to matlab) but it worked! Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulation, Tuning, and Visualization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by