フィルターのクリア

Plotting data from .csv file

55 ビュー (過去 30 日間)
Pierre
Pierre 2019 年 4 月 30 日
回答済み: Junior Jules Francois 2021 年 10 月 1 日
Hello,
I'm trying to find the solution since few days, but without results. I would like to plot my collected data from an accelerometer. There are 4 header lines and I want to plot the first four columns (which are timestamp, x, y and z axis). I tried several solutions found on internet but they didn't work for me.
Thank you for your help.
(MATLAB R2018b)
  2 件のコメント
Bob Thompson
Bob Thompson 2019 年 4 月 30 日
How exactly are you looking to organize your plots? Do you want x, y, and z individually against time? 3D contours? Gonna need more information before we can give a more detailed answer.
Here is a sample of how you should be able to load and create a 2D plot.
data = csvread('mydatafile.csv',4); % Read the data
plot(data(:,1),data(:,2)) % Plot x vs time
If there are other things you are stuck with, please expand with more specifics.
Pierre
Pierre 2019 年 4 月 30 日
Yes exactly, I would like x, y, z individually against time, in 2D. Something like the attached image. You can also find the csv file attached.
Thank you for you answer.

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

採用された回答

KSSV
KSSV 2019 年 4 月 30 日
data = csvread('mydatafile.csv',4); % Read the data
t = data(:,1) ;
x = data(:,2) ;
y = data(:,3) ;
z = data(:,4) ;
plot(t,x'r',t,y,'b',t,z,'g')
legend('x','y','z')
  3 件のコメント
Ratih Widiastuti
Ratih Widiastuti 2020 年 3 月 16 日
Hi. I tried those script, but I didn't work. My csv file contain data and text. I can import successfully the csv file with the following script:
A=importdata('Ratih1403202001a.csv');
disp(A);
disp(A.data);
But It is hard to plot the data. I want time as x axis and temperature, humidity, wind velocity or solar radiation as y axis. I also attached the error command and my csv file.
Can you help me please?
Thank you
KSSV
KSSV 2020 年 3 月 16 日
You should use csvread to read the csv file. Also read about xlsread, readtable.

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

その他の回答 (1 件)

Junior Jules Francois
Junior Jules Francois 2021 年 10 月 1 日

カテゴリ

Help Center および File ExchangeGraphics Object Programming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by