Matlab plotting from a data table.

154 ビュー (過去 30 日間)
Joseph Chudnovsky
Joseph Chudnovsky 2021 年 5 月 15 日
回答済み: Pranav Verma 2021 年 5 月 18 日
Hello!
I have a data table CSV file. I want to take data from one column of this data and put it in a plot with another column. In the end I would like to have one column on the x-axis and one on y axis. I am having trouble with this so how would I go about doing this?

採用された回答

Pranav Verma
Pranav Verma 2021 年 5 月 18 日
Hi Joseph,
From your question I understand that you have a CSV file containing multiple columns and you want to plot data from these columns.
You can read the CSV file first and then get the required columns and plot these against each other.
Use readmatrix function in MATLAB to read the CSV file and the extract the columns based on your requirement.
data = readmatrix('file.txt');
% for eg, if we want the first and second column to be plotted against each
% other
axes_x = data(:,1);
axes_y = data(:,2);
plot(axes_x, axes_y);
Please go through the plot function documentation for further information on plot.
Hope it helps!
Thanks

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTables についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by