how to form a new vector from an old one with a loop

1 次查看(过去 30 天)
Dear All, I hope that you are all well
I hope I will be able to explain my problem as good as it should.
I have three one column vector, the vectors size is m.
I would like to build a new vector let say we name it VectorA, this vector contain the 1st value of Vector 1 and it will repeat the picking the value at a regular step let say 30 from vector until the end.
Then the vector B it will take the second value from the vector 1 and with the same concept and repeated steps.
the number of vectors created equal to the Number of step used to pick values.
if the size of original vector is not devised on the step chosen, the code need to fill the vector constructed with zeros.
  2 个评论
Rik
Rik 2021-8-20
What have you tried, and can you give a small example?
Mohammed Lamine Mekhalfia
Hi Rik.
Thanks for the feedback.
well I successfully constructed one vector I call it blade that take the first value of sensor1 then with a constant step (29) he take 500 value from Sensor1 to form Blade1.
Blade2 to blade29 need to use the same but I do not know how to integrate them to that code.
clc
clear all
T = readtable('Results for 400 rpm.xls');
n=29 %Number of Blade
OPR=T.OPR;
OPR= OPR(~isnan(OPR));
OPR=repelem(OPR,n);
Sensor1=T.Sensor1;
Sensor2=T.Sensor2;
Sensor3=T.Sensor3;
Sensor1(Sensor1<OPR(1)) = []
Sensor2(Sensor2<OPR(1)) = []
Sensor3(Sensor3<OPR(1)) = []
size(OPR)
% a=size(OPR)
% b=size(OPR)/29
size(Sensor1)
size(Sensor2)
size(Sensor3)
h=1
for m=0:1:500
y=Sensor1(1+(29*m))
blade1(h)=y
h=h+1
end

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by