Question

Are you able to help me by explaining how to import data from a .csv file...

Are you able to help me by explaining how to import data from a .csv file into MATLAB using the import data wizard? I need to use the 'Generate Function' option in the import data wizard. How do I then call this data in MATLAB?

Please help me

Thank you

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Step 1: Open the file(s) in the Import Tool.

Step 2: Click Import Selection, and then select Generate Function. The Import Tool generates code similar to the following excerpt, and opens the code in the Editor.

function data = importfile(filename,startRow,endRow)
%IMPORTFILE Import numeric data from a text file as a matrix.
...

Step 3: Save the function.

Step 4: In a separate program file or at the command line, create a for loop to import data from each text file into a cell array named myData:

numFiles = 25;
startRow = 2;
endRow = inf;
myData = cell(1,numFiles);

for fileNum = 1:numFiles
    fileName = sprintf('myfile%02d.txt',fileNum);
    myData{fileNum} = importfile(fileName,startRow,endRow);
end

Each cell in myData contains an array of data from the corresponding text file. For example, myData{1} contains the data from the first file, myfile01.txt.

Add a comment
Know the answer?
Add Answer to:
Are you able to help me by explaining how to import data from a .csv file...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • --------__--------__Python--------__--------__ You will be reading in the data from the file SalesJan2009.csv. When you do, you...

    --------__--------__Python--------__--------__ You will be reading in the data from the file SalesJan2009.csv. When you do, you need to save all the items from the PRICE field into a list called amtCollected. After you get them all in that list, you will need to create a variable called total that holds the sum of all the numbers in the list. Then create a variable called avg that holds the average of the numbers in the list. Now, print the following strings:...

  • Use the csv file on spotify from any date Code from lab2 import java.io.File; import java.io.FileNotFoundException;...

    Use the csv file on spotify from any date Code from lab2 import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; public class SongsReport {    public static void main(String[] args) {               //loading name of file        File file = new File("songs.csv"); //reading data from this file        //scanner to read java file        Scanner reader;        //line to get current line from the file        String line="";       ...

  • How to make a table from a csv file without using prettytable or pandas. I have...

    How to make a table from a csv file without using prettytable or pandas. I have to use format I'm trying to... I'm trying to get a column for "Type", "Total", and "Percent" from TipJoke.csv file. import csv with open('TipJoke.csv', newline='') as csv_file: filereader = csv.reader(csv_file, delimiter=' ') for row in filereader: print( '{:2} {:3} {:4}'.format('Type', 'Total', 'Percent')) print(', '.join(row))

  • Can someone help me create a script in PowerShell along with a csv file for 5...

    Can someone help me create a script in PowerShell along with a csv file for 5 users. I will really appreciate. Please explain in step by step because i am new to this. the csv should contain 5 user. i want to create 5 users .

  • Please help explaining this problem to me. Thank you in advance! 4. Consider the Exxon stock...

    Please help explaining this problem to me. Thank you in advance! 4. Consider the Exxon stock discussed in class, which can go up or down 20% per year and has an initial value of $82. The current annual risk free rate is 1%, compounded annually. You are offered a 5-year European "hybrid" option with strike price $80. This option can be declared, after exactly 3 years, by the purchaser, to be either a call or a put. Find the value...

  • According to Wikipedia , a comma-separated values (CSV) file is a delimited text file that uses...

    According to Wikipedia , a comma-separated values (CSV) file is a delimited text file that uses a comma to separate values. A CSV file stores tabular data (numbers and text) in plain text. Each line of the file is a data record. Each record consists of one or more fields, separated by commas. The use of the comma as a field separator is the source of the name for this file format. A company has text data that is not...

  • 1. Create a table that will hold the data in avgprice kwh state.csv. This .csv file...

    1. Create a table that will hold the data in avgprice kwh state.csv. This .csv file contains the annual data from 1990-2012 on the average energy price per kilowatt hour (KwH) by state and provider type. Implement the following queries: • Print each row that has Tennessee as state, order the result by year in descending order. • Print the average residential, commercial, industrial, and transportation price for the state of Texas from the year 1990-2012. 2. Create the tables...

  • Task 4 Download the temperatures.txt file from Moodle. The file contains temperature data which h...

    Use the Matlab to solve this one, please! Task 4 Download the temperatures.txt file from Moodle. The file contains temperature data which has beern collected once a day and contains noisy data. Write a MATLAB m-file that performs the following: Read the temperature values from temperatures.txt into a vector A. B. C. Plot the temperature against time using red diamond markers. Without using loops, remove the noisy data using the following rules: I Any temperature value above 45°C is invalid...

  • yes you will need matlab software Can someone please help me. attached is the exercise i...

    yes you will need matlab software Can someone please help me. attached is the exercise i am doing in matlab. also attached is the exercise that i am suppose to be doing.also attached is part a of my code and part b. also attached is an error code i am getting. can someone please help me with this. thanks. explain in detail what i am doing wrong and what i need to do to fix it. you use enogn polnts...

  • PLEASE DO IT IN PYTHON, THANK YOU! CSV file: This is a file containing plain text...

    PLEASE DO IT IN PYTHON, THANK YOU! CSV file: This is a file containing plain text where each line in the file represents one record of information, and each piece of info in the record is separated by a single comma. Luckily the values won't ever contain commas themselves for this project. But they might start or end with non visible characters (e.g. space, tab). Thus, you must remove the leading and trailing spaces when you store the data in...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT