現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
How can I obtain the data from the scope for a waveform
1 回表示 (過去 30 日間)
古いコメントを表示
Hi, I need data from the scope at a certain time. The waveform obtained is sinusodial. I've connected "To simulink" from where I want to get the data. I need to get the value of the waveform at time 4.85. I think this is one of the basic questions. I am not so sure of syntax of the command. Please help.
4 件のコメント
John D'Errico
2014 年 3 月 7 日
It looks like you got an answer, but you are not using it properly. Your issue, not that of the person who answered the question.
Shivakumar
2014 年 3 月 7 日
No, I didn't get the answer. I tried his example to my problem. I am not able to get solution to my problem. If I got the answer, I have accepted his answer. Please check that my question is explained in the last two comments. I am still in need of the solution.
Mischa Kim
2014 年 3 月 7 日
編集済み: Mischa Kim
2014 年 3 月 7 日
I have to concur with John, I believe I did provide an answer. One which you even got to work. I believe so especially because I am confident in your ability to check out your simout1 object, identify its time vector component and adapt the syntax I showed you accordingly.
I am sure you did not mean to, but you might come across as one of those constantly dissatisfied users that eventually are flagged (figuratively) in the contributors community.
Shivakumar
2014 年 3 月 7 日
Kim, Please don't take me wrong. I flagged it because I want to make the question active and to get the answer. I don't have any dissatisfaction or complaints on your given answer. There are no other wrong intentions, Kim. I thank you for taking time to answer my question. If you go throw my comments, you will understand my problem of not getting the required solution.
採用された回答
Mischa Kim
2014 年 3 月 1 日
編集済み: Mischa Kim
2014 年 3 月 1 日
One option would be to add a Digital Clock block as shown below and set the sampling time to 4.85. This way this time stamp is automatically added to your time vector that is saved in the workspace.
In MATLAB you can then simply search for the data point at t=4.85, e.g.,
hold on
plot(tout,simout(:,2))
plot(tout(tout==4.85), simout(tout==4.85,2),'rs') % for the above model
22 件のコメント
Shivakumar
2014 年 3 月 5 日
Hi, I dont want to plot the data. I want the value at 4.85 seconds to be stored as a variable A in the M-file.
Shivakumar
2014 年 3 月 5 日
This is the syntax I have to get the maximum value of a waveform.
for i = 1: length(simout1.time(:,1))
if simout1.time(i,1) == 0.1
j = i;
break;
end
end
j
max_val = max(simout1.signals.values(j:end,1))
In the same way, I need a code to get the data exactly at 4.85 seconds.
Mischa Kim
2014 年 3 月 6 日
Just as shown above, I'd assume (since I do not know the exact structure of your data)
val_485 = simout1.signals.values(simout1.time(simout1.time(:,1)==4.85),1);
Shivakumar
2014 年 3 月 6 日
First I am trying the same kind of solution for the model example you gave above. This is the error I got when I used the above command.
??? Attempted to access simout1.time(:,1); index out of bounds because size(simout1.time)=[0,0].
Mischa Kim
2014 年 3 月 6 日
If you are using my example model you also need to use the attached code and variable names. In this case
val_485 = simout(tout==4.85,2);
will work. In my last comment I was trying to guess your data structure and come up with a solution. Notice that your workspace variable is called simout1 whereas mine is simout. So the following command "should" work for your model (and not mine)
val_485 = simout1.signals.values(simout1.time(simout1.time(:,1)==4.85),1);
Shivakumar
2014 年 3 月 6 日
For the command
val_485 = simout(tout==4.85,2); This is the error I got.
??? Index exceeds matrix dimensions.
Mischa Kim
2014 年 3 月 6 日
Double-click the simout block and set Save Format to Array. You probably have a different setting there. When I run the model I get in the MATLAB command window
val_485 = simout(tout==4.85,2)
val_485 =
-0.990546535966713
Shivakumar
2014 年 3 月 6 日
編集済み: Shivakumar
2014 年 3 月 6 日
I got the same answer. But I tried the same to my model but I am not getting the result. Instead, it is showing that the matrix is empty. I've attached the model here. I need to find the value of both simouts at 4.85. I've tried different formats in simout. Please help. Thanks in advance.
John D'Errico
2014 年 3 月 8 日
My guess is that testing for t == 4.85 is a problem. Testing for (abs(t-4.85)<10*eps) might be a better idea. It might also resolve why the poster failed to get it to work.
Mischa Kim
2014 年 3 月 8 日
John, with the Digital Clock you can set an exact time stamp in the tout vector.
Shivakumar, what needs to be done (initialized) to run your model?
Mischa Kim
2014 年 3 月 10 日
編集済み: Mischa Kim
2014 年 3 月 10 日
In this particular case only (there is a time stamp at t = 4.85) you can simply find the value with
simout.signals.values(find(simout.time==4.85))
The Digital Clock block is not necessary.
Shivakumar
2014 年 3 月 10 日
simout.signals.values(find(simout.time==4.85))
ans =
Empty matrix: 0-by-1
This is the result I got, Kim
Mischa Kim
2014 年 3 月 10 日
Shivakumar, I downloaded the model you attached in your last comment, and ran it. I get
simout.signals.values(find(simout.time==4.85))
ans =
1.6031
Shivakumar
2014 年 3 月 10 日
I still get the same problem. I use MATLAB 7.6.0. Do you think different versions is making the difference here?
Mischa Kim
2014 年 3 月 10 日
Possible, but I do not think so.
- Do you see the object simout in the workspace?
- When you type simout.signals.values and simout.time do you get the values of the two arrays?
Mischa Kim
2014 年 3 月 11 日
What happens, when you execute...
simout.time(end)
ans =
5
find(simout.time==4.85)
ans =
97001
simout.signals.values(ans)
ans =
1.6031
simout.signals.values(find(simout.time==4.85))
ans =
1.6031
Shivakumar
2014 年 3 月 11 日
I thank you Kim for your effort and time. This command helped me to get the answer.
val=simout.signals.values(97001)
I thank you very much. :)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Programmatic Model Editing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)