cancel
Showing results for
Show  only  | Search instead for
Did you mean:
Visitor
6,032 Views
Registered: ‎06-22-2008

## How to use vectors in MCode block from System Generator?

Why dosn't this works?

function z = SegundaTentatTeste(y)
um = [0 1 2 3 4 5 6 7];
z=um(3)
end

It says this in the Simulation Diagnostcis:

"Error("SegundaTentatTeste.m"): Syntax error: Encountered "1" at line 2, column 9"

1 Solution

Accepted Solutions
Visitor
6,264 Views
Registered: ‎06-22-2008

Found it:

function z = SegundaTentatTeste(y)
persistent v, v = xl_state([0.000000, 0.000001, 0.000002, 0.000003], {xlUnsigned, 100, 90});
z=xfix({xlUnsigned, 300, 160},v(0))
end

2 Replies
Visitor
6,018 Views
Registered: ‎06-22-2008

I found out how to do it:

function z = SegundaTentatTeste(y)
persistent v, v = xl_state(1, 2, 3, 4], 100, 90);
z=v(0)
end

But now i have another question, how do i use Xfix? I tried this:

function z = SegundaTentatTeste(y)
persistent v, v = xl_state([xfix({xlUnsigned, 100, 90},0.000), xfix({xlUnsigned, 100, 90},0.001), xfix({xlUnsigned, 100, 90},0.002),xfix({xlUnsigned, 100, 90},0.003)], 100, 90);
z=v(0)
end

Visitor
6,265 Views
Registered: ‎06-22-2008

Found it:

function z = SegundaTentatTeste(y)
persistent v, v = xl_state([0.000000, 0.000001, 0.000002, 0.000003], {xlUnsigned, 100, 90});
z=xfix({xlUnsigned, 300, 160},v(0))
end