How to replace table cell values with cell value multiplied by 0.0254?
Show older comments
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 Comments
Rik
on 21 Feb 2018
Your if-statement doesn't check for a text in your cell or table. And which is it: a cell or a table. The two data types are different in how they work. Unfortunately it is a bit difficult (and sometimes impossible) to use colon notation for cells.
Please give us a small example of HabEx3P, so we can help you write the code that works for your data.
Hao Tang
on 21 Feb 2018
Peter Perkins
on 21 Feb 2018
Please see my answer to your nearly identical question in another post you made yesterday:
Answers (0)
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!