How can I correct this error?

3 visualizaciones (últimos 30 días)
Mallouli Marwa
Mallouli Marwa el 8 de Jun. de 2018
Comentada: Mallouli Marwa el 12 de Jun. de 2018
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 comentarios
Stephan
Stephan el 8 de Jun. de 2018
Editada: Stephan el 8 de Jun. de 2018
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 el 10 de Jun. de 2018
Hi
See Data1 as attached.
I want also to show disp over tmp instead
Thanks for help

Iniciar sesión para comentar.

Respuesta aceptada

Stephan
Stephan el 11 de Jun. de 2018
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 comentarios
Mallouli Marwa
Mallouli Marwa el 12 de Jun. de 2018
Thanks
Mallouli Marwa
Mallouli Marwa el 12 de Jun. de 2018
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')

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by