How to develop a ramp up of values into a matrix

2 visualizaciones (últimos 30 días)
Adil Saeed
Adil Saeed el 24 de Ag. de 2022
Comentada: Adil Saeed el 25 de Ag. de 2022
I am trying to develop a ramp up. so i have an empty matrix named SL, and im trying to assign values to it. I want the first PnC(1), (50 values in this case) of the SL matrix to be a ramp up from 200 to 210. A ramp up being a literal ramp, so the values increase based on the gradient between 200 and 210 and the rest of the SL matrix, the values being 210.
My code and model is rather long so ive tried to include the relevant code. What i have at the moment is a steady step up (first 50 values being 200 and then >50 being 210).
%Number of Positions and Impacts
In = [50, 60, 75, 375, 420, 360];
Pn = sum(In);
PnC = cumsum(In);
%Time
T = 5400;
INT = 900;
TINT = 0:INT:T;
n = numel(TINT);
TVpieces = cell(1, n-1);
for iter = 1:n-1
Inc = INT/In(iter);
TVpieces{iter} = TINT(iter):Inc:(TINT(iter+1)-Inc);
end
TV = [TVpieces{:}];
SL = zeros(Pn,1);
for i = 1:Pn
%Source Level
if i<=PnC(1)
SL(i) = 200; %(1/90)*TVpieces{1,1} +
else
SL(i) = 210; %+ randi([-1 1]);
end
end
set(plot(TV,SL,'.'),'markersize',3)
as you can see noted out i have tried to develop the ramp up but having no success.
  1 comentario
Adil Saeed
Adil Saeed el 25 de Ag. de 2022
i have just editted my original post to make more sense in terms of the code, i am still unable to produce the graph i want within my code

Iniciar sesión para comentar.

Respuesta aceptada

Matt J
Matt J el 24 de Ag. de 2022
n=100; PnC=50;
SL=repelem(210,1,n);
SL(1:PnC(1))=linspace(200,210,PnC(1));
plot(SL); axis padded
  4 comentarios
Adil Saeed
Adil Saeed el 24 de Ag. de 2022
it does, the graph is good, but it doesnt fit into my code due to different matrix sizes as shown above
Adil Saeed
Adil Saeed el 25 de Ag. de 2022
I accepted this as I was able to use and manipulate what you did for what was needed

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by