create matrix in for loop with dynamic variable

조회 수: 7 (최근 30일)
Janae Csavina
Janae Csavina 2015년 3월 16일
댓글: Stephen23 2025년 4월 28일
I am wanting to replace the following:
%sensor 1 through 19 are numerical arrays of data.
i=19; %Sensor #
sensor=[sensor1 sensor2 sensor3 sensor4 sensor5 sensor6 sensor7 sensor8 sensor9 sensor10 sensor11 sensor12 sensor13 sensor14 sensor15 sensor16 sensor17 sensor18 sensor19];
with:
f=1;
for f=1:i
evaluate([sensor(:,f)= 'sensor' num2str(f)]);
f=f+1;
end
Any suggestions?
  댓글 수: 2
Geoff Hayes
Geoff Hayes 2015년 3월 17일
Janae - why are you doing this after you have created the 19 local variables? Why not just create/update sensor when you read (or determine) the sensor data for each of the 19 arrays?

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by