Comments on: Setting the Strings in a Table to a Constant https://blogs.mathworks.com/videos/2019/02/14/setting-the-strings-in-a-table-to-a-constant/?s_tid=feedtopost Stuart uses video to share his experiences solving problems with MATLAB day-to-day, interesting new features, plus tips and tricks he has picked up along the way. Wed, 13 Mar 2019 19:28:58 +0000 hourly 1 https://wordpress.org/?v=6.2.2 By: Stuart McGarrity https://blogs.mathworks.com/videos/2019/02/14/setting-the-strings-in-a-table-to-a-constant/#comment-89844 Fri, 15 Feb 2019 14:13:40 +0000 https://blogs.mathworks.com/videos/?p=4102#comment-89844 Nice. Much simpler than cellfun.

]]>
By: Nicolas Schoonbroodt https://blogs.mathworks.com/videos/2019/02/14/setting-the-strings-in-a-table-to-a-constant/#comment-89548 Fri, 15 Feb 2019 08:43:47 +0000 https://blogs.mathworks.com/videos/?p=4102#comment-89548 There are often several ways to do something, and in this specific case, to replace “every string in the table with a known value”, one other way could be to use indexing by variable type, using vartype.

% let's create a table T with some filler content
T = table("Some", "text", 1, 2, 3, "other", "text")

% First step: create a subscript looking for strings
S = vartype("string");

% Use it to change the values. 
% I'm using the '{' indexing to say that I'm interested by the content, not the container
T{:,S} = "dummy"
]]>