An easy way to apply a transformation to many data points

2 次查看(过去 30 天)
Hello, I have a list of over 100 data points in the form:
BAM_186_Torque_8Nov_0656 BAM_186_Torque_8Nov_0657 BAM_186_Torque_8Nov_0658
etc...
I am current applying an RMS function to them using the following code:
RMS_BAM_186_Torque_8Nov_0656 = rms(BAM_186_Torque_8Nov_0656); RMS_BAM_186_Torque_8Nov_0657 = rms(BAM_186_Torque_8Nov_0657); RMS_BAM_186_Torque_8Nov_0658 = rms(BAM_186_Torque_8Nov_0658); RMS_BAM_186_Torque_8Nov_0659 = rms(BAM_186_Torque_8Nov_0659); RMS_BAM_186_Torque_8Nov_0700 = rms(BAM_186_Torque_8Nov_0700); RMS_BAM_186_Torque_8Nov_0701 = rms(BAM_186_Torque_8Nov_0701); RMS_BAM_186_Torque_8Nov_0702 = rms(BAM_186_Torque_8Nov_0702); RMS_BAM_186_Torque_8Nov_0703 = rms(BAM_186_Torque_8Nov_0703);
My question is, how could I put these into an iterative loop to clean up my code and make my programming easier?
Thank you!

回答(1 个)

Matt J
Matt J 2012-11-9
编辑:Matt J 2012-11-9
Put your data points into the columns A(:,i) of a matrix instead. Then just do
rms_A=zeros(1,size(A,2));
for i=1:100
rms_A(i)=rms(A(:,i));
end

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by