How to input a stream of matrix elements from Matlab into a simulink model?
5 views (last 30 days)
Show older comments
Hi, I'm trying to design a hardware-based 3x3 convolution filter.
And I need to figure out how to input the matrix of the image to the simulink model, one element at a time.
What block do I have to use? I've tried several blocks but it leads me to nowhere, the problem usually lie around the file format, or am I missing some block parameters to be set?
Thanks in advance!
1 Comment
Accepted Answer
Azzi Abdelmalek
on 14 Jul 2013
Edited: Azzi Abdelmalek
on 14 Jul 2013
If you mean by one element at a time:
at t=0, s=A(1,1,1),
at t=ts, s=A(2,1,1)
at t=2*ts, s=A(1,2,1)
and so on
you can use a from workspace block, you have to specify a variable
x=[t s]
with
t=[0:ts:numel(A)*ts-ts]' % ts is a sample time
s=A(:)
3 Comments
Azzi Abdelmalek
on 14 Jul 2013
Edited: Azzi Abdelmalek
on 14 Jul 2013
In this case, if your matrix is A, in Matlab Command Windows write:
A=A'
n=numel(A)
vector_time=t=[0:ts:(n-1)*ts]'
s=A(:)
x=[vector_time s]
In simulink model, use a from workspace block with parameters
data=x
sample time=ts
You should also set the final time of simulation parameter to
vector_time(end)
More Answers (0)
See Also
Categories
Find more on Computer Vision with Simulink in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!