How to replace table cell values with cell value multiplied by 0.0254?

조회 수: 4 (최근 30일)
Hao Tang
Hao Tang 2018년 2월 21일
댓글: Peter Perkins 2018년 2월 21일
I want to look through the rows, find a specific text. If that text exists, then go to column 4 to 6 and replace those values by multiplying that value by 0.0254. How can I do that? I have this code but it doesn't work
num_rows = size(HabEx3P,1);
num_cols = size(HabEx3P,2);
for i = 1:1:num_rows
if ~exist('GRID','var')
for j = 4:1:6
HabEx3P(:,j) = HabEx3P(:,j).*0.0254;
end
end
end
  댓글 수: 3
Hao Tang
Hao Tang 2018년 2월 21일
I also meant to use exist and not ~exist.
I've attached the HabEx3P matlab table
So to clarify, look in first column for the word GRID, then go to the 4th to 6th column and replace that Value with Value*0.0254
For some reason, I always get an error 'Undefined operator '*' for input arguments of type 'table'
Eventually, the table will have lots of unique words like GRID, but if I can get just replacing values with GRID values working then the rest should be straightforward

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

답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by