Integrate function in an interval of time into simulink function block
Mostrar comentarios más antiguos

ok, i have this vector G generated by a code , and it represent the solar radiation over all the year; so it's a kind of periodic function. This code is inside a function block in simulink, i put the final part of the code.
....if (h<h_S && h>-h_S) % if true is day
G=Gdr+Gdf+Grf; % [w/m^2] radiazione globale su una superficie comunque orientata
else
G=0;
end
end
This vector G, has 365*24*3600 elements, as well the time vector t.
What i need to do is to integrate this vector G, for each month separately.
For the whole month of January it will be from 0 to (3600*24*31)th element,and for february, for example, from (3600*24*31)th to (3600*24*59)th.
So for the 1st day of january, for example, i tried to integrate from the 1st value until the 86400 th,that rapresent in second the whole day:3600*24.
i tried with
for i=1:86400
Gen=integral(G,1,86400);
end
where t is the time vector of the whole year, so of 365*24*3600 elements.
The program get this error:
"The function 'integral' is not supported for standalone code generation. See the documentation for coder.extrinsic to learn how you can use this function in simulation.
Function 'MATLAB Function1' (#23.2558.2571), line 73, column 11: "integral(G,t)"
Alternatively, i was thinking to generate a vector for each month, using
Gen=G(1:86400)
But the program says: "Index exceeds array dimensions. Index value 2 exceeds valid range [1-1] of array G. Error in 'radiazione_totale/MATLAB Function1' (line 73) Gen=G(1:86400);"
Can you help me please?
thanks
1 comentario
Jan
el 20 de Oct. de 2017
The code does not work. What is the purpose of this line:
h(i)<h_alba(i) && h(i)>-h_alba(i)
? Perhaps an "if" is missing?
The body of the loop in the second code does not depend on the loop counter i. So what is "G(t)"?
Whenever you mention an error, post the complete message. Without the message and without a running code, the readers have to guess, what the problem could be.
Please edit the question and insert more details.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Discontinuities en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!