title: Initial value of a signal Simulink
body: <p>I am working on a yacht velocity prediction program (VPP) in Simulink (I can't upload the image as I am a new user to this forum, apparently).</p>
  
  <p>Solving the problem requires me to know the apparent wind speed and angle (VA and beta, respectively) in order to obtain the force generated by the sails and hence the net force, acceleration and ultimately speed of the boat. However, VA depends on the boat speed (VS). I tried putting in the initial value of the latter through the integrator block which converts the acceleration into speed but I keep getting the following error inside the "Apparent wind" m-function: "Index expression out of bounds. Attempted to access element 3. The valid range is 1-1.". Note that if I rearrange the model and feed the function with a constant value, say, it will work (although the resultant boat speed will not be physically correct). Listing of the m-function is shown below.</p>
  
  <p>Simplified block diagram:</p>
  
  <p>[VT,gamma] -> Apparent wind -> aero- &amp; hydrodynamics -> force/mass -> acceleration -> 1/s -> VS</p>
  
  <pre><code>function [VA, beta] = fcn(inputs)
  % 1 - gamma  % true wind heading [deg]
  % 2 - VT  % true wind speed [kts]
  % 3 - VS
  
  %#codegen
  
  % apparent wind angle [deg]
  beta=atan(sin(inputs(1)*pi/180)/(cos(inputs(1)*pi/180)+inputs(3)/inputs(2)))/pi*180;    
  
  % apparent wind speed [kts]
  VA=sin(inputs(1)*pi/180)/sin(beta*pi/180)*inputs(2);    
  
  end
  </code></pre>
  
  <p>EDIT: Please find the attached flowchart of the model now that I can actually upload one.</p>
  
  <p><img src="https://i.stack.imgur.com/mK4Po.png" alt="enter image description here"></p>