-2

これをプロットしたい

f(x)=3*(1-x)+7*x+8.314*T((1-x)*(lnx)+x*(lnx))+20*x(1-x)

から~までT変化し、間隔は{合計 20 個のグラフがすべて同じ}02000100

for ループとプロット関数を含む非常に基本的なコードを示します。PS : 私はの初心者ですMATLAB

4

2 に答える 2

1

WordPress へようこそ。:) ループなしでこれを行う方法は次のとおりです。

% Define your function in terms of x and T
% Note that we use .* instead of * - this does a pairwise multiply
%  instead of a matrix or vector multiply
f = @(x,T) 3*(1-x)+7*x+8.314*T.*((1-x).*log(x)+x.*log(x))+20*x.*(1-x);

% Set your domain
x = linspace(0, 10, 101);
T = (0:100:2000);

% Compute your function for all values of x and T
tmp = bsxfun(f, x, T');

% Plot your output, all at the same time
plot(x, tmp)
于 2013-08-22T22:00:37.880 に答える