How can I correct this error?

1 次查看(过去 30 天)
Hello
I have done this program , no error is displayed but any curve is displayed.
Can you help me
clc; clear ; close all;
% acceleartion + displacement
cd Z:\Stage\Travail_fait\marwa
load data1; tmp = data1(:,1); disp = data1(:,2); acc = data1(:,3);
figure(1) plot(tmp, acc, 'b',tmp,acc,'r.') xlable('time (s)'); ylabel('Acceleration (ms^(-2))');
  2 个评论
Stephan
Stephan 2018-6-8
编辑:Stephan 2018-6-8
Hi,
your question is a little bit unclear. What is the problem?
clc;
clear ;
close all;
% acceleartion + displacement
cd Z:\Stage\Travail_fait\marwa
load data1;
tmp = data1(:,1);
disp = data1(:,2);
acc = data1(:,3);
figure(1)
plot(tmp, acc, 'b',tmp,acc,'r.')
xlabel('time (s)');
ylabel('Acceleration (ms^(-2))');
The actual code gives you a blue line with the acc over tmp values and additionally red dots from also acc over tmp. Do you want to show disp over tmp instead? Or does your curve not look like it should?
There was just one mistake in
xlable('time (s)');
which should be
xlabel('time (s)');
Please tell your problem a little more exactly. If possible attach data1 file.
Best regards
Stephan
Mallouli Marwa
Mallouli Marwa 2018-6-10
Hi
See Data1 as attached.
I want also to show disp over tmp instead
Thanks for help

请先登录,再进行评论。

采纳的回答

Stephan
Stephan 2018-6-11
Hi,
to show disp over tmp Change the plot command:
plot(tmp, acc, 'b',tmp,disp,'r.')
which will give you this result:
You could also work with subplots using the following code:
figure(1)
subplot(2,1,1)
plot(tmp, acc, 'b')
xlabel('time (s)');
ylabel('Acceleration (ms^(-2))');
subplot(2,1,2)
plot(tmp, disp, 'b')
xlabel('time (s)');
ylabel('Displacement');
Which gives you:
Best regards
Stephan
  2 个评论
Mallouli Marwa
Mallouli Marwa 2018-6-12
I have added this part in the program that calculate the Fourier
Transform of the voltage but the trend is not well.
The curve FRF wanted attached is the best trend.
So How can I ameloirate the trend of this FRF found (figure3 in the program).
The program is:
%% %script traitement signal %objet : traitement signal MPF clc; clear; close all; cd Z:\Matlam\Curves_oscillo_Pc %%
%% load 'data1.txt';
tmp = data1(:,1);
disp = data1(:,2);
acc = data1(:,3);
figure(1)
plot(tmp,acc,'b',tmp,acc,'r.');
xlabel('time (sec)');
ylabel('Acc (ms^{-2})');
%on récupère les données de Oscilloscope en Volt
load 'data1V.txt';
tmpV = data1V(:,1);
Volt = data1V(:,2);
%Voltb = 40e-3*ones(size(tmpV));
figure(2)
plot(tmpV,Volt,'b',tmpV,Volt,'r.');
xlabel('time (sec)');
ylabel('Voltage(V)'); %%
L=length(tmp)
Lv=length(tmpV)
Fs = 5000; % Sampling frequency
NFFT = 2^nextpow2(L) % Next power of 2 from length of y
NFFTV = 2^nextpow2(Lv) % Next power of 2 from length of y
figure(3)
VOLT = fft(Volt,NFFT)/L; % Calcul de la FFT
amplitude = 2*abs(VOLT(1:NFFT));
f = Fs/2*linspace(0,1,NFFT/2);
semilogy(f(1:NFFT/12),2*abs(VOLT(1:NFFT/12)))
xlabel('frequency')
ylabel('FRF Volatage')

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by