How to plot a part of an array?

117 ビュー (過去 30 日間)
Ahmed
Ahmed 2024 年 4 月 5 日
コメント済み: Manikanta Aditya 2024 年 4 月 5 日
lets say i have
x = 1:20
and i have this eqution;
y = 2x+3
how to plot (x,y) where x only goes up to 10 while the whole 20 numbers are still avalible on the plot, just as empty space?
In another words i want to adjust the size of my x axis and y axis without it being automatically adjusted by Matlab.

採用された回答

Manikanta Aditya
Manikanta Aditya 2024 年 4 月 5 日
Hi, check this:
% Create the x vector
x = 1:20;
% Calculate y based on the equation
y = 2 * x + 3;
% Create a figure and plot the data
figure;
plot(x, y);
% Set the x-axis limits to display the full range of 1 to 20
xlim([1 20]);
% Add labels and a title
xlabel('x');
ylabel('y');
title('Plot of y = 2x + 3');
Thanks!
  7 件のコメント
Ahmed
Ahmed 2024 年 4 月 5 日
I always felt that graphs in matlab are tricky. But i started to understand how to do this.
Appreciate it mate.
Manikanta Aditya
Manikanta Aditya 2024 年 4 月 5 日
Great to hear, Hope you become proficient soon :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by