How to scatter plot when the values are i.e 1,1 and 1,10 grid

조회 수: 1 (최근 30일)
Ihaveaquest
Ihaveaquest 2022년 8월 22일
댓글: Ihaveaquest 2022년 8월 22일
trying to avoid repeating code
plot(sparams.frequency_GHz(1),delta(:,1))
plot(sparams.frequency_GHz(41),delta(:,1))
and for this when i try doing the same it does not work , possible to combine ??
plot(sparams.frequency_GHz(:,1),delta(:,2:end), plot_color,'HandleVisibility','off')
  댓글 수: 2
Kevin Holly
Kevin Holly 2022년 8월 22일
Is sparams a table or struct array? How many rows and columns are there for frequency_GHz data? rows and columns for delta?
Ihaveaquest
Ihaveaquest 2022년 8월 22일
struct array
both
Freq 41X16
delta 41x16

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

채택된 답변

Kevin Holly
Kevin Holly 2022년 8월 22일
편집: Kevin Holly 2022년 8월 22일
What do you want on your y and x axes?
sparams.frequency_GHz = 10*rand(41,16);
delta = rand(41,16);
This one separates the data based on the columns (16 groups)
scatter(sparams.frequency_GHz,delta,'filled')
xlabel('Frequency (GHz')
ylabel('Delta')
This one separates the data based on the rows (41 groups)
scatter(sparams.frequency_GHz',delta','filled')
xlabel('Frequency (GHz')
ylabel('Delta')
  댓글 수: 3
Kevin Holly
Kevin Holly 2022년 8월 22일
편집: Kevin Holly 2022년 8월 22일
Are you saying there are 10 possible frequency values in the 41x16 matrix?
sparams.frequency_GHz = randi(10,41,16);
sparams.frequency_GHz
ans = 41×16
10 8 8 1 10 2 6 1 2 5 8 6 6 6 8 8 3 6 3 6 7 5 4 2 1 9 1 5 1 3 7 6 9 9 9 2 9 3 2 7 2 5 4 1 5 8 8 3 8 5 1 4 10 10 4 7 6 9 6 8 5 4 2 1 10 6 8 3 8 7 9 2 8 8 4 8 3 5 6 4 7 3 5 3 9 5 4 4 1 6 6 5 1 10 1 10 3 6 1 3 2 9 10 9 8 4 4 5 4 4 4 7 6 4 1 10 2 5 2 6 7 3 10 3 6 6 7 1 8 3 1 4 2 7 1 8 10 1 1 9 3 7 5 1 4 7 5 2 10 6 5 5 8 10 7 10 2 9 10 9
delta = rand(41,16);
Create logical array when freq equals 1 or 10.
At_one = sparams.frequency_GHz==1;
At_ten = sparams.frequency_GHz==10;
At_one_ten = logical(At_one + At_ten)
At_one_ten = 41×16 logical array
1 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 1 1 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 1 0 1 1 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 1 0 0 1 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 1 0 0 1 1 1 0 0 1 0 0 0 1 1 0 1 0 0 0 0 0 0 1 0 0 0 1 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 1 0 1 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 1 0 0 0 0 1 1 1 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 1 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 0 1 0 0 0 1 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0
scatter(sparams.frequency_GHz(At_one_ten),delta(At_one_ten),'filled')
xlabel('Frequency (GHz')
ylabel('Delta')
Ihaveaquest
Ihaveaquest 2022년 8월 22일
yes thatst the plot i need - Thank you

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by