Difference between revisions of "Octave/Storage"

From Coder Merlin
 
Line 12: Line 12:
We can append the contents of a string to an existing array using the following command:
We can append the contents of a string to an existing array using the following command:
{{ConsoleLine|octave:18>|A {{Equal}} [A; strread(s, "%n")];}}
{{ConsoleLine|octave:18>|A {{Equal}} [A; strread(s, "%n")];}}
{{MerlinMultipageExperienceNavBar}}

Latest revision as of 12:22, 14 April 2022

Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder

Reading from a Local File[edit]

We can read the contents of a local file using the following command:

octave:16> s = fileread ("sample.csv");

Reading from a Remote URL[edit]

We can read the contents of a remote URL using the following command:

octave:17> s = urlread ("https://www.codermerlin.com/users/john-williams/sample.csv");

Reading from a String[edit]

We can read the contents of a string using the following command, interpreting each value read as a Double:

octave:18> A = strread(s, "%n");

Appending from a String[edit]

We can append the contents of a string to an existing array using the following command:

octave:18> A = [A; strread(s, "%n")];