-2

我想绘制这个

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

T从到变化,0间隔2000100{总共20个图都在同一个}

给出一个涉及 for 循环和绘图功能的非常基本的代码。PS:我是初学者MATLAB

4

2 回答 2

1

欢迎来到 Matlab。:) 以下是我们在没有循环的情况下如何做到这一点:

% 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 回答
0
f=@(x,T) 3*(1-x)+7*x+8.314*T*((1-x).*log(x)+x.*log(x))+20*x.*(1-x);
T=0:100:2000;
x=linspace(0,10,100);
for i=1:length(T)
    plot(x,f(x,T(i)));
    hold on;
end
于 2013-08-22T21:19:25.763 回答