How to plot table T such that column R is for X-axis and column I is for Y-axis and column V is the values between them? (I need to change the shape of dots according to V value such that if it is more than 4.5 for example it plots dot else it is *)

조회 수: 1 (최근 30일)
R I V
_____ ______ _______
1000 0.0001 4.901
2000 0.0001 4.802
3000 0.0001 4.703
4000 0.0001 4.604
5000 0.0001 4.505
6000 0.0001 4.4059
7000 0.0001 4.3069
8000 0.0001 4.2079
9000 0.0001 4.1089
10000 0.0001 4.0099
the table has 100 points such that I is from 0.0001 to 0.001 with a 0.0001 increment
and R is as shown from 1k to 10k with 1k increment for each I value

답변 (1개)

Benjamin Kraus
Benjamin Kraus 2023년 12월 31일
You cannot use two different markers on a single line, so your best bet is two overlapping lines, and you can use MarkerIndices to control which vertices on your line use markers. For example:
R = 1000:1000:10000;
I = 0.0001*ones(size(R));
V = [4.901, 4.802, 4.703, ...
4.604, 4.505, 4.4059, ...
4.3069, 4.2079, 4.1089, 4.0099];
tbl = table(R,I,V);
% Plot the same line twice
p = plot(tbl.R,tbl.I,tbl.R,tbl.I);
% The first line will have a solid line style, dot markers, and use
% MarkerIndices to control which vertices have markers.
p(1).LineStyle = '-';
p(1).Marker = '.';
p(1).MarkerIndices = find(tbl.V>4.5);
% The second line will have no line style, * markers, and use
% MarkerIndices to control which vertices have markers.
p(2).Color = p(1).Color;
p(2).LineStyle = 'none';
p(2).Marker = '*';
p(2).MarkerIndices = find(tbl.V<=4.5);
  댓글 수: 1
Benjamin Kraus
Benjamin Kraus 2023년 12월 31일
Note, if you are using the lastest version of MATLAB, I would leverage two more recent features (table support in the plot command, and SeriesIndex) and write this code a little differently:
R = 1000:1000:10000;
I = 0.0001*ones(size(R));
V = [4.901, 4.802, 4.703, ...
4.604, 4.505, 4.4059, ...
4.3069, 4.2079, 4.1089, 4.0099];
tbl = table(R,I,V);
% Plot the same line twice, leveraging table support in the plot command
% added in R2022a.
p = plot(tbl, "R", ["I", "I"]);
% The first line will have a solid line style, dot markers, and use
% MarkerIndices to control which vertices have markers.
p(1).LineStyle = '-';
p(1).Marker = '.';
p(1).MarkerIndices = find(tbl.V>4.5);
% Make sure both lines use the same color by synchronizing their
% SeriesIndex.
p(2).SeriesIndex = p(1).SeriesIndex;
% The second line will have no line style, * markers, and use
% MarkerIndices to control which vertices have markers.
p(2).LineStyle = 'none';
p(2).Marker = '*';
p(2).MarkerIndices = find(tbl.V<=4.5);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by