Stuart’s MATLAB Videos

Watch and Learn

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the Original version of the page.

Setting the Strings in a Table to a Constant 2

Posted by Stuart McGarrity,

I have a table with many columns, some of which are stings. I want to set all the string values to a constant string.

Features covered in this code-along style video, which is less coherent than usual, include:

Follow me (@stuartmcgarrity) if you want to be notified via Twitter when I post.

Play the video in full screen mode for a better viewing experience. 

2 CommentsOldest to Newest

Nicolas Schoonbroodt replied on : 1 of 2
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"