使用matlab绘制示意图的示例

这篇博客介绍了如何使用MATLAB进行示意图的绘制,包括添加图例、标题等操作,并展示了调用LaTeX字体的示例,帮助读者掌握MATLAB的图形美化技巧。
摘要由CSDN通过智能技术生成

在本示例中,将给出如何用matlab绘制示意图,添加图例,添加标题等等,以及在matlab中调用LaTeX字体的命令。

代码如下:

clear;clc;close all

% Initialize  symbolic variables
syms x f df

% example
disp('An Example, Plot Function and Derivative')
f = sin(x^2)
df = diff(sym(f));
pretty(df)

xx = linspace(-5,5);
x = xx;
fx = eval(f);
dfx = eval(df);

plot(xx,fx,'r-','LineWidth',2)
hold on
plot(xx,dfx,':b','LineWidth',2)
grid on

set(gca,'FontSize',12);
set(gca,'LineWidth',2);  
set(gca,'TickDir','out');

xlabel('x','FontSize',20);
ylabel('$f(x)$, $\frac{df(x)}{dx}$','FontSize',20,'Interpreter','latex')
title(['$' latex(f) '$ and Derivative $' latex(df) '$'] ,'FontSize',30,'Interpreter','latex')
legend(...
    '$f(x)$',['$\frac{df(x)}{dx}$=$' latex(df) '$'],...
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值