Info

此问题已关闭。 请重新打开它进行编辑或回答。

Can someone help me out with this code, it doesn't seem to be giving the correct output. I have MATLAB 2017a and this code ran on MATLAB 2013a

1 次查看(过去 30 天)
clc
clear all
close all
syms n a x y z
a=input('Please enter the matrix:');
bb=a-n*eye(size(a,1));
cc=det(bb);
gg=solve(cc);
%Eigenvectors
b=[a-n*eye(size(a))]*[x;y];
for i=1:2
d=subs(b,n,gg(i));
end
c=solve(d);
e=[c.x c.y];
disp(c);
g=subs(e,z,1);
disp(e);
disp(g);

回答(1 个)

Elizabeth Reese
Elizabeth Reese 2017-8-18
I think that there are two changes that you are seeing to the Symbolic Math Toolbox here.
The first is that the order of elements in gg changed between the versions. Is there a different way that you can assign d to avoid this inconsistency?
The second change is that a Name-Value pair was introduced between R2013a and R2017a called ReturnConditions. You can add this to a call to solve to parameterize the solution. This was done in R2013a without the flag which is why that outputs are functions of z. If you set this flag to true in R2017a, then you can achieve the same parameterization. When you use this Name-Value pair, the result stored in c will include a field called parameters and another called conditions. You can use the parameters to do the substitution later on when you assign g.

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by