How to plot this graph on Matlab?
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
HI GUYS I WOULD LIKE TO PLOT THIS GRAPH ON MATLAB ? CAN ANYONE TELL ME HOW TO DO IT ? THANKS IN ADVANCE
2 件のコメント
Kristen Chappel
2021 年 2 月 16 日
Rik
2021 年 2 月 20 日
Are you aware that using only upper case letters is considered SHOUTING?
採用された回答
Image Analyst
2021 年 2 月 16 日
You can use rectangle() to plot the circle and oval.
You can use text() to place text labels on the plot.
12 件のコメント
Kristen Chappel
2021 年 2 月 16 日
THANKS @Image Analyst, BUT I WOULD LIKE TO KNOW HOW TO ADD LINE 1 PARAMETER AND LINE 2 PAPAMETER. TEXT IS NOT IMPORTANT, CAN YOU PLEASE TELL ME, IS IT POSSIBLE?
Image Analyst
2021 年 2 月 17 日
Kristen, you just had to modify the examples in the help, like this:
% Initialization steps.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 13;
% Define oscillation parameters.
period = 10;
t = linspace(0, 5 * pi, 100);
y = 30 * sin(2 * pi * t / period);
% Define graphics parameters:
rectangleHeight = 0.15;
rectangleWidth = 0.15;
rectangleLowerLeftX1 = 0.0;
rectangleLowerLeftY1 = 0.1;
lineX = 15;
% Set up axes.
grid on;
ylim([-0.150, 0.3]);
xlim([-0.15, 0.25]);
xlabel('X', 'FontSize', 15);
ylabel('Y', 'FontSize', 15);
faceColor = [.95, 1, .95];
axis('equal');
% Start the movement:
% Place a rectangle at the current y location.
r = rectangle('Position', [rectangleLowerLeftX1, rectangleLowerLeftY1, rectangleWidth, rectangleHeight], ...
'Curvature', [1, 1], ...
'LineWidth', 3, ...
'EdgeColor', 'b', ...
'FaceColor', faceColor);
title('Rectangles and circles and ovals', 'FontSize', 15);
% Do the oval
rectangleHeight = 0.09 * 2;
rectangleWidth = 1.07;
rectangleLowerLeftX1 = -1;
rectangleLowerLeftY1 = -0.09;
r = rectangle('Position', [rectangleLowerLeftX1, rectangleLowerLeftY1, rectangleWidth, rectangleHeight], ...
'Curvature', 1, ...
'LineWidth', 3, ...
'EdgeColor', 'b', ...
'FaceColor', faceColor);
xlim([-0.15, 0.25]);

This looks pretty close to the figure you posted. Adapt parameters as needed.
Image Analyst
2021 年 2 月 17 日
What function would you like to do that? I don't believe rectangle(), xlabel(), ylabel(), or title() take a "line1" or "line2" parameter. If you have a line as (x,y) coordinates, you can use plot():
plot(x, y, 'r--', 'LineWidth', 2); % Plot dashed red line.
Kristen Chappel
2021 年 2 月 17 日
編集済み: Kristen Chappel
2021 年 2 月 17 日
@Image AnalystIT DOESNOT PLOT THE LINE USING ABOVE CODE , FOR EXAMPLE I GIVEN
X= 2;
Y=3;
plot(x, y, 'r--', 'LineWidth', 2); % Plot dashed red line.
THEN IT NOT PLOT ANY LINE , WHY ?
THANKS
Image Analyst
2021 年 2 月 17 日
Because using -- plots a line between adjacent coordinates. A line has at least two coordinates, but you gave only one, so there can be no line to the next point (which doesn't exist). You can see the point by using a marker:
plot(x, y, 'r.-', 'LineWidth', 2, 'MarkerSize', 25); % Plot dashed red line.
You can plot a line like this:
x = 1 : 10;
y = rand(1, length(x));
plot(x, y, 'r.-', 'LineWidth', 2, 'MarkerSize', 25); % Plot dashed red line.
Kristen Chappel
2021 年 2 月 17 日
THANKS @Image Analyst, IS THEIR NY WAYS TO ENTER THE VALUE OF X AND Y MANUALLY ACCORDING TO OUR CHOICE AND THEN BY CONSIDERING THIS OUR POINT PLOT THAT ENTIRE LINE? THANKS
Kristen Chappel
2021 年 2 月 17 日
SORRY @Image Analyst, NO I AM STILL FACING THE PROBLEM I AM NOT ABLE TO ADD MORE THAN TWO POINT. IS THEIR ANY WAYS TO ENTER THE VALUE OF X AND Y MANUALLY ACCORDING TO OUR CHOICE AND THEN BY CONSIDERING THIS OUR POINT PLOT THAT ENTIRE LINE? THANKS
Kristen Chappel
2021 年 2 月 17 日
SORRY @Image Analyst, NO I AM STILL FACING THE PROBLEM I AM NOT ABLE TO ADD MORE THAN TWO POINT. IS THEIR ANY WAYS TO ENTER THE VALUE OF X AND Y MANUALLY ACCORDING TO OUR CHOICE AND THEN BY CONSIDERING THIS OUR POINT PLOT THAT ENTIRE LINE? THANKS
Kristen Chappel
2021 年 2 月 17 日
SORRY @Image Analyst, NO I AM STILL FACING THE PROBLEM I AM NOT ABLE TO ADD MORE THAN TWO POINT. IS THEIR ANY WAYS TO ENTER THE VALUE OF X AND Y MANUALLY ACCORDING TO OUR CHOICE AND THEN BY CONSIDERING THIS OUR POINT PLOT THAT ENTIRE LINE? THANKS
Image Analyst
2021 年 2 月 17 日
Experiment around with the input() or inputdlg() function.
Kristen Chappel
2021 年 2 月 17 日
@Image AnalystI DIDN'T UNDERSTAND CAN YOU PLEASE EXPLAIN IT IN MORE DETAILS?
Les Beckham
2021 年 2 月 18 日
In order to plot more than one point on a plot you need to provide more than one data point. You have not explained where the data for 'Line 1' and 'Line 2' is coming from. As soon as you figure out where that data is coming from it will be easy to plot it along with the other shapes that Image Analyst showed you how to plot.
You should not really post repeated requests for help (especially in all caps, please turn off your caps lock, it is usually interpreted as "yelling") when you haven't explained what you really want or, apparently, listened to the previously provided suggestions..
Explain how you want to "ENTER THE VALUE OF X AND Y MANUALLY ACCORDING TO OUR CHOICE". As Image Analyst suggested, you could prompt for them on the command line (using input()) or create a dialog to ask for the values (using inputdlg()). Or, if you want to do it by clicking on the figure you could try ginput().
Read the documentation for those functions. Here are links to the online docs: input, inputdlg, ginput.
Read the examples and come back with specific questions when you have tried something and it didn't work. Also, post the code that isn't working and show any error messages that you get (the complete error message) and explain what you expect and why what you get isn't what you want.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Graphics Object Properties についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
