matlab 读取文件画图,用MATLAB读取txt文件并绘图

该博客介绍了如何使用MATLAB生成幅值为5、频率为10Hz的正弦信号,将数据保存到MySin.txt文件中,然后读取该文件并绘制正弦波形图。通过设置Y轴范围、添加标题和坐标轴标签,完成图形的美化。
摘要由CSDN通过智能技术生成

幅值为5、频率为10Hz的正弦信号,并写入数据文件MySin.txt,并读取文本文件MySin.txt 中的数据文件,进行绘图.

% Applying the Mysin function to generate a sine waveform

...with amplitude and frequency are 5 and 10 respectively,and then

...writing the sine wave data to the text file-Mysin.txt

clear;clc;

A = 5; % The amplitude of sinusoid.

fre = 10; % The frequency of sinusoid.

N = 1024; % The number of sampling points.

Fs = 1024; % Sampling frequency.

dt = 1/Fs; % Time interval.

t = (0:(N-1))*dt; % Time vector.

Xt = A*sin(2*pi*f*t + 3*pi/4); % Generating a sine function.

file_type = fopen('D:\MySin.txt','w'); % open text file-MySin.txt.

...(Creat a text file unless this text file is exist) fprintf(file_type,'%12f\n',Xt); % Formatting the input data,and the to the text file. fclose(file_type); % close th

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值