arrays - Signal created with matlab function block in simulink -


I want to generate an arbitrary linear signal from the matlab function block in simulink. I want to use this block because then, when I generate a signal from a sequence in Stateflow, I want to control it. I try to extract a function from a function with a value and any other time as the following code:

  `function y = sig (u) if u == 1 t = ([0 10 20 30 40 50 60]); T = [(20 20 40 40 60 60 0]); Sitem = [t ']; S.signals (1) value = [t].; S.signals (1) = 1 dimension.; Other N = ([0 0 0 0 0 0 0]); S.signals (1) value = [n '].; End y = s.signals (1). Value end  

The idea is that U == 1 generates the signal, U == 0 generates zero output

  function y = sig (U)  

[0, 0]); Cant = input ('number of digits'); For n = drange (1: slang) s (n, 1) = input ('time'); S (n, 2) = input ('temperature'); Finally y = [s] and y = [0] end of end

I can not generate the signal in either case

In the first case, I get such errors :

There is no field 'signal' in this structure; The new field can not be added when the structure is read or used

or

Error in the port width or dimension 'Portrait of template' 2 / Metallop Function / U ' One dimensional vector containing 1 element.

or

The first assignment for the undefined function or variable 'y' local variable determines its orbit.

And in the second case:

Try and hold are not supported for code generation,

'MATLAB function' during the parsing of MATLAB function # 23)

Error width in port width or dimension is a dimensional vector with 'Tamtstrstrf 2 / Metallop Function / U' 1 element of Port Port 1.

I am very grateful for any contribution.

PD: Sorry for my english xd

There are many errors in your code You will need to read more about Matlab

  1. here S = ([0, 0]); You can declare an array with only two elements so that the size

    Work for you

      function y = sig (u) if u == 1 %% does not get the size of the field = input ('number of digits \ r \ N '); %% two areas form a structure of S = straight ('time', zero (1, slang), 'temperature', zero (1, slang); N = 1 for: slang S. Time (n) = input (strcat ([strcat (['time' num2str (n)]) '='])); S.temperature (n) = input (strcat ([strcat (['temperature' ... num2str (n)]) '' '']])); Assigned output as the cell of the end %% structure y = {S}; Else y = 0; The end result  

    to use the result simply

      s = y {1}; S.time; S.temperature;  

    To convert the result to a 2D array

      2dArray = [y {1}. time; Y {1}. Temperature [];  

    Work with an array

      function y = sig (u) if u == 1 ct = input ('number of numbers \ r \ n' ); S = []; For N = 1: slang S (1, n) = input (strcat ([strcat (['time' num2str (n)]) '='])); S (2, n) = input (strcat ([strcat (['temperature' ... num2str (n)]) '' '']])); End y = s; Else y = 0; End End  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -