Function to write data to a specifc line in a text file

I don't really know how to go about this.
I just want a simply function that I can call in a script. This function would take in an initially blank text file, and add data to it, line by line. The line number would be an input of the function. The data that it would write into the file would be the output of the script.
any ideas on how to get started?

This question is closed.

Asked:

on 24 Jul 2016

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!