Replace certain columns in a structure array

조회 수: 3 (최근 30일)
Tomer
Tomer 2024년 5월 15일
댓글: Tomer 2024년 5월 15일
Hi. I have a structure array, Data, of size (1 x120). The 5th column of the field Data.Temp contains zeroes. I want to replace these zeroes with a number 20 from Data(30).Temp to Data(60).Temp. Also, I want to replace these zeroes from Data(61).Temp to Data(80).Temp with a number 24. I am unable to perform this operation. I kindly request some help from the community.

채택된 답변

Walter Roberson
Walter Roberson 2024년 5월 15일
[Data(30:60).Temperature] = deal(20);
[Data(61:80).Temperature] = deal(24);
  댓글 수: 7
Walter Roberson
Walter Roberson 2024년 5월 15일
You renamed the field since the original posting.
Also it turns out that the fields contain arrays of data.
for K = 30:60; Data(K).Temp(:,5) = 20; end
for K = 61:80; Data(K).Temp(:,5) = 24; end
Tomer
Tomer 2024년 5월 15일
@Walter Roberson: Thank you. It is working now.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by