% 定义常量 T0 = 10e-12; % 宽度的半高全宽 beta2 = -20e-27; % 色散参数 Ld = T0^2 / abs(beta2); % 色散长度 C = 5; % 绘图 figure; hold on z = linspace(0,4Ld,1000); for m = [4, 2, 1] sigma_sig0 = sqrt(1+gamma(1/(2m))./gamma(3/(2m))Cbeta2.z/T0^2+m^2(1+C^2).gamma(2-1/(2m))./gamma(3/(2m)).(beta2z/T0^2).^2); plot(z/Ld,sigma_sig0); end xlabel('距离,z/Ld'); ylabel('展宽因子'); yticks(logspace(log10(0.1), log10(100), 4)); set(gca, 'YScale', 'log'); yticklabels({'0.1', '1', '10', '100'}); legend('m=4','m=2','m=1');将上述代码的曲线类型改变
时间: 2024-01-29 07:04:30 浏览: 167
可以将原来的 plot 函数改为 semilogy 函数,这样就可以将曲线的纵坐标改为对数坐标显示,代码如下:
```matlab
figure; hold on
z = linspace(0,4*Ld,1000);
for m = [4, 2, 1]
sigma_sig0 = sqrt(1+gamma(1/(2*m))./gamma(3/(2*m)) * C * beta2 * z / T0^2 + m^2 * (1+C^2) * gamma(2-1/(2*m))./gamma(3/(2*m)) .* (beta2*z/T0^2).^2);
semilogy(z/Ld,sigma_sig0);
end
xlabel('距离,z/Ld');
ylabel('展宽因子');
yticks(logspace(log10(0.1), log10(100), 4));
legend('m=4','m=2','m=1');
```
这样就可以将曲线的纵坐标改为对数坐标显示,从而更好地展示数据。
相关问题
%图3.5 T0 = 10e-12; % 宽度的半高全宽 beta2 = -20e-27; % 色散参数 Ld = T0^2 / abs(beta2); % 色散长度 C = 5; figure; hold on m = 4; z = linspace(0,4*Ld,1000); sigma_sig0 = sqrt(1+gamma(1/(2*m))./... gamma(3/(2*m))*C*beta2.*z/T0^2+m^2*(1+C^2).*... gamma(2-1/(2*m))./... gamma(3/(2*m)).*(beta2*z/T0^2).^2); plot(z/Ld,sigma_sig0); m = 2; z = linspace(0,4*Ld,1000); sigma_sig0 = sqrt(1+gamma(1/(2*m))./... gamma(3/(2*m))*C*beta2.*z/T0^2+m^2*(1+C^2).*... gamma(2-1/(2*m))./... gamma(3/(2*m)).*(beta2*z/T0^2).^2); plot(z/Ld,sigma_sig0,'--'); m = 1; z = linspace(0,4*Ld,1000); sigma_sig0 = sqrt(1+gamma(1/(2*m))./... gamma(3/(2*m))*C*beta2.*z/T0^2+m^2*(1+C^2).*... gamma(2-1/(2*m))./... gamma(3/(2*m)).*(beta2*z/T0^2).^2); plot(z/Ld,sigma_sig0,'-.'); xlabel('距离,z/Ld'); ylabel('展宽因子'); yticks(logspace(log10(0.1), log10(100), 4)); set(gca, 'YScale', 'log'); yticklabels({'0.1', '1', '10', '100'}); legend('m=4','m=2','m=1');简化上述代码
% 定义常量
T0 = 10e-12; % 宽度的半高全宽
beta2 = -20e-27; % 色散参数
Ld = T0^2 / abs(beta2); % 色散长度
C = 5;
% 绘图
figure; hold on
z = linspace(0,4*Ld,1000);
for m = [4, 2, 1]
sigma_sig0 = sqrt(1+gamma(1/(2*m))./gamma(3/(2*m))*C*beta2.*z/T0^2+m^2*(1+C^2).*gamma(2-1/(2*m))./gamma(3/(2*m)).*(beta2*z/T0^2).^2);
plot(z/Ld,sigma_sig0);
end
xlabel('距离,z/Ld');
ylabel('展宽因子');
yticks(logspace(log10(0.1), log10(100), 4));
set(gca, 'YScale', 'log');
yticklabels({'0.1', '1', '10', '100'});
legend('m=4','m=2','m=1');
阅读全文