Clear Filters
Clear Filters

How can I correct this error?

1 view (last 30 days)
Mallouli Marwa
Mallouli Marwa on 8 Jun 2018
Commented: Mallouli Marwa on 12 Jun 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 Comments
Stephan
Stephan on 8 Jun 2018
Edited: Stephan on 8 Jun 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 on 10 Jun 2018
Hi
See Data1 as attached.
I want also to show disp over tmp instead
Thanks for help

Sign in to comment.

Accepted Answer

Stephan
Stephan on 11 Jun 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 Comments
Mallouli Marwa
Mallouli Marwa on 12 Jun 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')

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!