How to develop a ramp up of values into a matrix

조회 수: 7 (최근 30일)
Adil Saeed
Adil Saeed 2022년 8월 24일
댓글: Adil Saeed 2022년 8월 25일
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
Adil Saeed
Adil Saeed 2022년 8월 25일
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

댓글을 달려면 로그인하십시오.

채택된 답변

Matt J
Matt J 2022년 8월 24일
n=100; PnC=50;
SL=repelem(210,1,n);
SL(1:PnC(1))=linspace(200,210,PnC(1));
plot(SL); axis padded
  댓글 수: 4
Adil Saeed
Adil Saeed 2022년 8월 24일
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 2022년 8월 25일
I accepted this as I was able to use and manipulate what you did for what was needed

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by