이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
errors in matlab function block in simulink
조회 수: 2 (최근 30일)
이전 댓글 표시
i am trying to create a matlab function block in the Simulink that generates square pulses as pulse generator but errors appear please help , I attached screenshots.
<<

>>


답변 (1개)
Azzi Abdelmalek
2016년 4월 11일
Your code is not correct. Plus, generating a puls train with Matlab function is not a good idea. You have to know that your Matlab function block, the way it's programmed, will outpu,t each sample time, an entire array.
You can generate such signal with from file block, from worksapce block or using repeated sequence
If you want to use from file block
Fs=1e+9
tend=10*4e-6
t=0:1/Fs:tend;
pulsewidth=1e-6
pulseperiods=(0:10)*4e-6
x=pulstran(t,pulseperiods,'rectpuls',pulsewidth)
v=[t;x];
save yourfile v
Then set the name "yourfile" in the frome file block
댓글 수: 28
mohamed samhy
2016년 4월 11일
should I write your code in the matlab function block or where please clarify ? ( and thanks for helping really appreciate it )
Azzi Abdelmalek
2016년 4월 11일
No, in a script, or Windows Command. The aim is to create the file that contains your signal.
mohamed samhy
2016년 4월 11일
I saved it by this name , how should I implement it now in the Simulink block ?
Azzi Abdelmalek
2016년 4월 11일
mohamed samhy
2016년 4월 11일
and the scope shows no square pulses , sorry for disturbance I really appreciate your helping
Azzi Abdelmalek
2016년 4월 11일
In model configuration parameters set the solver to discret. and set the stop time to tend
mohamed samhy
2016년 4월 11일
I adjusted the solver to discrete but I cant find how to set the stop time
Azzi Abdelmalek
2016년 4월 11일
no, set it to tend. because your frequency is very high 1e9. If you want to see quickly your pulse train, set the stop time to t(end) or tend
mohamed samhy
2016년 4월 11일
편집: mohamed samhy
2016년 4월 11일
it shows error because tend it is very big and maximum is 200000
mohamed samhy
2016년 4월 11일
편집: mohamed samhy
2016년 4월 11일
yes the period of my square train pulse which is 4 microseconds
Azzi Abdelmalek
2016년 4월 11일
편집: Azzi Abdelmalek
2016년 4월 11일
Have you read my previous comment? probably you have cleared the variable tend. before running your simulink model you need to set the variable tend to its original value
tend=10*4e-6
mohamed samhy
2016년 4월 11일
u mean from the variables in the matlab , ohh I thout Simulink is isolated from matlab . I will try now
mohamed samhy
2016년 4월 11일
I tried again same error , I got exhausted seems I cant do it , if u can send me a file I would really appreciate it , thanks again for all.
mohamed samhy
2016년 4월 11일
I have a problem in the Simulink model if u please lastly can send it to me , my attached file is same as yours because I did it by your step but the Simulink is hard to run without errors. thanks so much so far
mohamed samhy
2016년 4월 11일
https://www.dropbox.com/s/a5dlpl56eoohbhf/matfunc.zip?dl=0 this my Simulink file if u can attach your file and see what error appear that will be so helpful , thanks
mohamed samhy
2016년 4월 15일
편집: mohamed samhy
2016년 4월 15일
it did work ,man you are such a great helpful person hope u have a happy life for helping people so much . thanks again man :)
참고 항목
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 (한국어)



