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
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
採用された回答
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/189150/image.png)
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/189151/image.png)
Best regards
Stephan
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!