使用diary 命令,这里是一个例子。
%solve linear equations
diary hw6prob1.txt;
clear;
A=[4,-2,1;3,6,-4;2,1,8];
B=[20;-30;40];
Y=inv(A);
X=Y*B;
fprintf('The answers is: \n ');
X,
The
Y,
diary off;
红色的是关键所在,这两个命令之后,中间输出的X, Y就保存在hw6prob1.txt 。
请看输出结果
The answers is:
X =
2.3194
-2.9658
4.7909
Y =
0.1977 0.0646 0.0076
-0.1217 0.1141 0.0722
-0.0342 -0.0304 0.1141
没有评论:
发表评论