x = [1 2 3 4 5]; y = [10 8 6 4 2]; plot(x, y); xlabel('X-axis'); ylabel('Y-axis'); title('Example Line Plot');

8 ビュー (過去 30 日間)
valli
valli 2023 年 5 月 8 日
編集済み: Sulaymon Eshkabilov 2023 年 5 月 23 日
show the figure.
  5 件のコメント
Walter Roberson
Walter Roberson 2023 年 5 月 23 日
It's true. No-one has seen me physically for the last decade.
Alexander
Alexander 2023 年 5 月 23 日
I don't need a "mind reading toolbox", I only want to have a button: "Do what I want, you know whot I mean".

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

回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023 年 5 月 23 日
編集済み: Sulaymon Eshkabilov 2023 年 5 月 23 日
Based on your question's subject header, it can be stated that what you see in your plot is correct:
% You are trying to get a correct plot of x vs. y variables, which are x in
% an ascending order and y is in a descending order.
% Wht you are getting is correct.
x = [1 2 3 4 5];
y = [10 8 6 4 2];
plot(x, y);
xlabel('X-axis');
ylabel('Y-axis');
title('Example Line Plot');
% If you want to plot both x and y in an ascending order then, use this
% command for y:
y=sort(y, 'ascend')
y = 1×5
2 4 6 8 10
figure
plot(x, y)
xlabel('X-axis')
ylabel('Y-axis')
title('Example Line Plot')
% if you want to display x y values as given, then use xticks and
% xticklabels, yticks and yticklabels
figure
plot(x, y, 'ro--');
xticks(x)
xticklabels({'1', '2', '3', '4', '5'})
yticks(y)
yticklabels({'2', '4', '6', '8', '10'})
xlabel('X-axis')
ylabel('Y-axis')
title('Example Line Plot')
grid on

カテゴリ

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