Two S functions with different sampling rate

Hi,
I have two S functions connected with each other in one simulink model, one with sampling rate 0.05 and anothe with 0.2 sec, but the second one does not work, even I added rate transitions between them. When I set the sampling rates same at 0.05, the simulation runs without any problem. The reason I use different sampling rates is to increase the simulation speed, but sampling rate cannot be too large for the first system. Could you provide any suggestions to help out? Many thanks.

Antworten (2)

Aman Vyas
Aman Vyas am 19 Mär. 2020

0 Stimmen

Hi,
Simulink throws an error "SAMPLE RATE MISMATCH" whenever you try to run same model with two different sample rates. Pls proceed with either of these solutions:
A) Try using upsample and downsample block to balance out the sample so that error is removed.
B) Simulate two systems separately so as to run separate systems at different sample rates.
C) Try following this link as it points to similar problem
Follow these documentation links:
Hope this solves your issue.

4 Kommentare

Zhongyou Wu
Zhongyou Wu am 19 Mär. 2020
Hi Aman,
Thanks for your reply. I have tried the upsample and downsample blocks, but they don't solve my problem, i.e. the simulation can run, but the second system does not work. I guess my problem originates from the two S-Functions within one simulink model but with different sampling rates. As the two S-Functions interconnect with each other, it is impossible to seperate them and run individually. Thanks again.
Aman Vyas
Aman Vyas am 24 Mär. 2020
Bearbeitet: Aman Vyas am 24 Mär. 2020
Try using delay blocks to balance out. Or try sharing error you are receiving.
Zhongyou Wu
Zhongyou Wu am 27 Mär. 2020
Hi Mr. Vyas,
Thanks for your reply.
When I added the rate transition blocks, as in the figure of question. One automatically became a ZOH and another functioned as a Dealy block. Adding delays did not solve my problem. I guess the problem originates from the communications between the fast (first system) and slow (second system) system, but I am not exactly sure.
No error message appeared, but the second system does not function at all, i.e. it output zeros all the time, which is incorrect. Thanks again.
Aman Vyas
Aman Vyas am 27 Mär. 2020
Hello,
The problem you asked states you had different sampling rates and if in single system two different sample rates exist the simulation will throw the error sample rate mismatch.
But as you told that error is eradicated and is not showing up means the sample rate issue is gone and your block might not be working because of some other reason.
I feel now you need to check your logic as the thing you raised is not showing up now.

Melden Sie sich an, um zu kommentieren.

Zhongyou Wu
Zhongyou Wu am 27 Mär. 2020

0 Stimmen

Thanks. I need to figure out how to make them cooperate correctly.

1 Kommentar

Zhongyou Wu
Zhongyou Wu am 28 Mär. 2020
Thanks for your advice. I have tried these method. Unfortunately, none of them solves my problem.

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 16 Mär. 2020

Kommentiert:

am 28 Mär. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by