I have been looking for some time and I havent been able to find a solution to my problem yet.
Let me try to explain my problem and hopefully you guys can give me some help on how to solve this.
So I have a function:
function opTheta = funcDronessim(i,x_drone,y_drone,theta_gs,theta_d)
Which takes a position x_drone,y_drone and two angles theta_gs,theta_d as input.
I want to make this in simulink and not as a matlab script.
In a matlab script I would have written:
x_drone = 1:1:100;
y_drone = 50*ones(1,length(x_drone));
for i = 1:1:100
function opTheta = funcDronessim(i,x_drone(i),y_drone(i),theta_gs,theta_d)
theta_d = -pi + opTheta;
theta_gs = opTheta;
end
And this way I can update the theta_d and theta_gs which is the only ones I want to update right now.
My question is: How can I do this in Simulink?
What did I try? I tried to add a MATLAB function block and put the function funcDronessim in there.
Now my problem comes, since I have no idea how to make a "for i:1:100" in simulink and make the following code in simulink:
x_drone = 1:1:100;
y_drone = 50*ones(1,length(x_drone));
I tried to use a constant block and add 1:1:100 in it, but it doesnt give what I expected. Then I tried to make a vector (x_drone = 1:1:100) in a matlab script and use "from workspace" and in simulink "to workspace". But I think I dont really understand how this works, because it is making a really big matrix and not the vector I am expecting.
Do you have any idea of how this can be solved? I am totally lost and I have been using so many hours on this problem now and I assume its a really simple fix.