How to loop through columns on table and plot against first column?

36 ビュー (過去 30 日間)
Nicola Fairbairn
Nicola Fairbairn 2018 年 1 月 24 日
コメント済み: Dag Wang 2020 年 10 月 1 日
Okay so I'm massive amounts of data from a spectrometer and I'm wanting to plot multiple scans one on top of the other.
I have one excel file of 113 columns and 12,443 rows called CoolingHeating. The first column is called "WaveNumber" and I want this as my x axis. The other 112 columns are all scans and generically called VarName2 up to VarName113. I want each VarName column to be plotted against the x axis WaveNumber in the same plot, one on top of the other to create a continuum. The idea is that there should be 112 lines on the plot. I'm really, really rusty at programming and know it involves a For loop but I'm not 100% sure how to go about doing it.
So far all I have is:
plot(CoolingHeating.WaveNumber(2:12443),CoolingHeating.VarName2(2:12443));
which simply gives me the first scan. How do I add the other 111 columns in? I suspect xlsread might be required but I'm not sure.
  2 件のコメント
Peter Perkins
Peter Perkins 2018 年 1 月 24 日
This is a table, as in the data type, right? What's in the first row that you need to skip it? Did you read the spreadsheet with readtable, and 'ReadVariableNames' set to true?
Nicola Fairbairn
Nicola Fairbairn 2018 年 1 月 24 日
First row was just labelling in the excel spreadsheet

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2018 年 1 月 24 日
plot(CoolingHeating.WaveNumber(2:12443), CoolingHeating{2:12443, 2:end});
  3 件のコメント
Parthasarathy P.S.
Parthasarathy P.S. 2018 年 12 月 12 日
How to label each column in the graph then?
Dag Wang
Dag Wang 2020 年 10 月 1 日
To get legend with column names:
legend(CoolingHeating.Properties.VariableNames{2:end})

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by