Simulataneous equation solver code
古いコメントを表示
Hi, I am trying to come up with a simultaneous equation solver that will ask a user for the number of simultanous equations to be solved and the number of coefficients in the simultaneous equations after which a for loop will be used to enter the number of coeffiecients for the number of equations.
Attached is the matlab code
% function for coefficient entry
function s = myfunc_Q2a(x)
s=zeros;
for i=1:x
s(i)=str2double(inputdlg('Enter coefficients: '));
end
end
% script that calls on the above function
g=msgbox('Equation is in the form: x1*a1 + x2*a2 + an*xn= b ');
waitfor(g)
n=str2double(inputdlg('Enter the number of simultaneous equations to be solved: '));
x=str2double(inputdlg('Enter the number of coefficients in the equation: '));
A=zeros;
B=zeros;
s=zeros;
for j=1:n
z(j)=myfunc_Q2a(x);
end
I am receiving an error that states left and right hand side have different number of elements, however when I choose
n=2 and x=1 I dont receive an error.
1 件のコメント
Ghazwan
2022 年 10 月 11 日
is it maybe x=1 is the only integer you are entering?
You have a counter i=1:x. x has to be an integer.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Mathematics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!