An easy way to apply a transformation to many data points

2 Ansichten (letzte 30 Tage)
Matthew
Matthew am 9 Nov. 2012
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!

Antworten (1)

Matt J
Matt J am 9 Nov. 2012
Bearbeitet: Matt J am 9 Nov. 2012
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

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by