フィルターのクリア

Plotting professional MATLAB graph of given two txt files

10 ビュー (過去 30 日間)
Jimmy cho
Jimmy cho 2021 年 12 月 14 日
回答済み: Image Analyst 2021 年 12 月 15 日
Hello,
I'm having to two txt files lets say:
out1.txt
out2.txt
out1 txt has only integer values like this (as column):
100
200
300
400
out2 txt has only integer values like this(as column):
17
18
19
20
I want to plot a good graph (2-D professional graph) of value out1 txt (x axis) versus out2 txt (x axis), x axis called "time" , y axis called "value".
the line of the graph lets say it's a red line / graph.
Any idea how I can do that in matlab a function that gets as input two txt files and plot the graph of their value as I described above?
Much appreciated !

採用された回答

Voss
Voss 2021 年 12 月 14 日
x = load('out1.txt');
y = load('out2.txt');
figure();
plot(x,y);
xlabel('time');
ylabel('value');
  2 件のコメント
Jimmy cho
Jimmy cho 2021 年 12 月 14 日
but that don't plot the line / graph as red color , am I wrong?
Voss
Voss 2021 年 12 月 14 日
To get a red line:
plot(x,y,'r');

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2021 年 12 月 15 日
Try this
% Read in data
x = readmatrix('out1.txt');
y = readmatrix('out2.txt');
% Plot it.
plot(x, y, 'r-', 'LineWidth', 3); % Thick red line. Adjust as desired.
% plot(x, y, 'r.-', 'LineWidth', 3, 'MarkerSize', 25); % Alternative, if you want dots for markers.
xlabel('Time', 'FontSize', 20); % Adjust font size as desired.
ylabel('Value', 'FontSize', 20);
title('Here is my good graph', 'FontSize', 20);
grid on;
% Maximize figure
g = gcf;
g.WindowState = 'maximized'
See attached demo if you want to change anything else, like axes colors, tick marks colors/sizes/colors, etc.

カテゴリ

Help Center および File ExchangeSpecifying Target for Graphics Output についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by