Understanding a From Workspace block in Simulink

2 vues (au cours des 30 derniers jours)
Daniel Winstanley
Daniel Winstanley le 24 Mar 2022
I'm currently trying to use a from workspace block to access a certain data point within its connected to array. The array contains certain selected rows from a bigger datasheet. I want to be able to access the value of a certain data point and check it (within a matlab function block in simulink) to see if it is lower than another value.
When I try doing it through the method of: constant < array(col,row) it only come back with an error of:
Index expression out of bounds. Attempted to access element 3. The valid range is 1-1. More informationFunction 'MATLAB Function3' (#65.102.103), line 2, column 30: "3" Launch diagnostic report.
I know that im passing it the correct data as I could use it before in another part of the simulink, but instead just inserted it into a simulink multiplication block. he main thing I'm asking is if I need to reference it differently, through a format of: var.signals.values=[DataValues] for the data value or if im doing this completely wrong.
Can provide any extra information, code snip, or photos of the program to assit. I'm very new to simulink so may not understand the high technicalities required.
Thanks

Réponses (1)

arushi
arushi le 2 Sep 2024
Hi Daniel,
I understand that you are trying to access a specific data point from within the array and then perform a comparison within a MATLAB function block of Simulink. The error you are encountering is related to indexing of the array and the message indicates that you are trying to access an element at index 3, but the valid range is 1-1, which suggests that the array might not have the expected dimensions.
To address this issue, you can verify the dimensions of the array using the "size" function in MATLAB. This will help you confirm the dimensions of the array and ensure that your indices are within the valid range.
For additional information regarding 'size' function please refer to the following documentation:
I hope it helps!

Catégories

En savoir plus sur Simulink Functions dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by