mattryan8524
mattryan8524

Reputation: 7

How to plot .txt file

I have a text file with two columns, called Fx1. In column 1 it shows deflection calculations and in column 2 it shows force calculation (about 100).

I loaded the text file into matlab as a variable, called Fx1.

How do I plot this text file as a graph, with deflection as my x value, and force as my y value? Apparently, I am supposed to define my variables, but I do not know how to do so when I'm getting the data from a .txt file.

This is what I did and I did not get the correct graph:

plot(fx1)

Any ideas?

Here is a screenshot of my text file: Here is my text file. It continues for many values, I just copy and pasted the beginning

Here is a screenshot of my whole workspace, I am trying to make a plot for all txt files between Fx1-Fx9.

Matlab work space

Upvotes: 0

Views: 1113

Answers (1)

Saeed Bolhasani
Saeed Bolhasani

Reputation: 580

You should separate fx1 into two vector. Use these commands:

    x=fx1(:,2)';
    y=fx1(:,1)';
    plot(x,y);

In additional you can combine these three command to one command:

    plot(fx1(:,2)',fx1(:,1)');

Upvotes: 1

Related Questions