matlab怎么对mat文件的数据画图,求助大神!!!怎样把mat文件的每组数据计算之后调用画图...

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

b54d81fd46a28f24719e6955fcfe352d.png

如图我想把每列的数据平方之后相加再开根号,之后用matlab画图,matlab程序应该怎么写

我有画这三列图像的M文件

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Author: Mi Zhang

%Date: July, 2010

%File Name: displayData_acc.m

%Description: Visualize the 3-axis accelerometer data

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Fs = 100; % Sampling frequency = 100Hz

% Read the data

data = sensor_readings;

acc_x = data(: ,1);

acc_y = data(: ,2);

acc_z = data(: ,3);

% Parameter declaration

BIN_COUNT = 10; %

T = 1/Fs; %

Interval = 1000 / Fs; %

L = size(acc_x, 1); %

t = (0:L-1)*T; %

% Visualize the time series, histogram, and FFT

figure;

% Time series

subplot(3, 3, 1);

plot(t, acc_x);

grid on;

xlabel('Time (s)');

ylabel('Acceleration (g)');

title('X-Axis Data');

% Histogram

subplot(3, 3, 2);

hist(acc_x, BIN_COUNT);

grid on;

xlabel('Acceleration (g)');

ylabel('Count');

title('X-Axis Distribution');

% Spectral analysis

subplot(3, 3, 3);

NFFT = 2^nextpow2(L);

Y = fft(acc_x, NFFT)/L;

f = Fs/2*linspace(0,1,NFFT/2+1);

plot(f,2*abs(Y(1:NFFT/2+1)));

title('X-Axis Spectrum');

xlabel('Frequency (Hz)');

ylabel('|X(f)|');

% Time series

subplot(3, 3, 4);

plot(t, acc_y);

grid on;

xlabel('Time (s)');

ylabel('Acceleration (g)');

title('Y-Axis Data');

% Histogram

subplot(3, 3, 5);

hist(acc_y, BIN_COUNT);

grid on;

xlabel('Acceleration (g)');

ylabel('Count');

title('Y-Axis Distribution');

% Spectral analysis

subplot(3, 3, 6);

NFFT = 2^nextpow2(L);

Y = fft(acc_y, NFFT)/L;

f = Fs/2*linspace(0,1,NFFT/2+1);

plot(f,2*abs(Y(1:NFFT/2+1)));

title('Y-Axis Spectrum');

xlabel('Frequency (Hz)');

ylabel('|Y(f)|');

% Time series

subplot(3, 3, 7);

plot(t, acc_z);

grid on;

xlabel('Time (s)');

ylabel('Acceleration (g)');

title('Z-Axis Data');

% Histogram

subplot(3, 3, 8);

hist(acc_z, BIN_COUNT);

grid on;

xlabel('Acceleration (g)');

ylabel('Count');

title('Z-Axis Distribution');

% Spectral analysis

subplot(3, 3, 9);

NFFT = 2^nextpow2(L);

Y = fft(acc_z, NFFT)/L;

f = Fs/2*linspace(0,1,NFFT/2+1);

plot(f,2*abs(Y(1:NFFT/2+1)));

title('Z-Axis Spectrum');

xlabel('Frequency (Hz)');

ylabel('|Z(f)|');

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值