이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
How can I obtain the data from the scope for a waveform
조회 수: 5 (최근 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개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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 (한국어)
