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
How to develop a ramp up of values into a matrix
조회 수: 7 (최근 30일)
이전 댓글 표시
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.
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!