필터 지우기
필터 지우기

3D plot matrices

조회 수: 2 (최근 30일)
Ludwig
Ludwig 2024년 6월 6일
댓글: Matlab Pro 2024년 6월 6일
I need to create a 3D surface plot with the following data:
M100 = [19.8 29.305 38.425 48.37; 4.9 7.4 10.0 13.65];
M300 = [19.35 31.25 40.05 50.55; 7.6 12.65 16.65 21.15];
M500 = [20.05 30.0 40.5 49.9; 9.8 14.55 19.5 23.95];
M700 = [19.85 30.6 40.1 49.4; 10.6 17.0 22.15 27.2];
M900 = [20.65 30.7 39.15 48.25; 12.6 18.9 24.4 29.0];
f = [100:200:900];
For every frequency f is a set of power levels (the first row of the matrices) and a set of temperatures (second row of the matrices). Everything has to be in on plot. Thanks in advance.

채택된 답변

Mathieu NOE
Mathieu NOE 2024년 6월 6일
hello
maybe this ?
M100 = [19.8 29.305 38.425 48.37; 4.9 7.4 10.0 13.65];
M300 = [19.35 31.25 40.05 50.55; 7.6 12.65 16.65 21.15];
M500 = [20.05 30.0 40.5 49.9; 9.8 14.55 19.5 23.95];
M700 = [19.85 30.6 40.1 49.4; 10.6 17.0 22.15 27.2];
M900 = [20.65 30.7 39.15 48.25; 12.6 18.9 24.4 29.0];
f = [100:200:900];
M = [M100;M300;M500;M700;M900]; % combine data
pow = M(1:2:end,:); % power data
temp = M(2:2:end,:); % temperature data
% "power" surface plot
samples = (1:size(pow,2));
figure
% imagesc(f,samples,pow)
surf(f,samples,pow')
title(' "power" plot')
xlabel('Frequency')
ylabel('Samples')
zlabel('Power')
colorbar('vert');
% "temperature" surface plot
samples = (1:size(pow,2));
figure
% imagesc(f,samples,temp)
surf(f,samples,temp')
title(' "temperature" plot')
xlabel('Frequency')
ylabel('Samples')
zlabel('Temperature')
colorbar('vert');
  댓글 수: 1
Ludwig
Ludwig 2024년 6월 6일
Yes, thank you very much!

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

추가 답변 (1개)

Matlab Pro
Matlab Pro 2024년 6월 6일
Attached is my solution;
% Power levels: row1
% temperatures : row2
M100 = [19.8 29.305 38.425 48.37; 4.9 7.4 10.0 13.65];
M300 = [19.35 31.25 40.05 50.55; 7.6 12.65 16.65 21.15];
M500 = [20.05 30.0 40.5 49.9; 9.8 14.55 19.5 23.95];
M700 = [19.85 30.6 40.1 49.4; 10.6 17.0 22.15 27.2];
M900 = [20.65 30.7 39.15 48.25; 12.6 18.9 24.4 29.0];
f = [100:200:900];
% The code is just to extract the powerLeveles & Temperartures
M ={M100,M300,M500,M700,M900};
PowLvl = cell2mat(cellfun(@(x) x(1,:),M,'UniformOutput',false)');
Temps = cell2mat(cellfun(@(x) x(2,:),M,'UniformOutput',false)');
% Plotting
fig = figure;
ax = axes('Parent',fig);
plot3(PowLvl,Temps,f,'-o','Color','b','MarkerSize',10,...
'MarkerFaceColor','#D9FFFF','Parent',ax);
grid(ax,'on')
Good luck
  댓글 수: 1
Matlab Pro
Matlab Pro 2024년 6월 6일
For a step representation:
% Power levels: row1
% temperatures : row2
M100 = [19.8 29.305 38.425 48.37; 4.9 7.4 10.0 13.65];
M300 = [19.35 31.25 40.05 50.55; 7.6 12.65 16.65 21.15];
M500 = [20.05 30.0 40.5 49.9; 9.8 14.55 19.5 23.95];
M700 = [19.85 30.6 40.1 49.4; 10.6 17.0 22.15 27.2];
M900 = [20.65 30.7 39.15 48.25; 12.6 18.9 24.4 29.0];
f = [100:200:900];
f1 = repmat(f,4,1)';
% The code is just to extract the powerLeveles & Temperartures
M ={M100,M300,M500,M700,M900};
PowLvl = cell2mat(cellfun(@(x) x(1,:),M,'UniformOutput',false)');
Temps = cell2mat(cellfun(@(x) x(2,:),M,'UniformOutput',false)');
% Plotting
fig = figure;
ax = axes('Parent',fig);
stem3(PowLvl,Temps,f1,'-o','Color','b','MarkerSize',10,...
'MarkerFaceColor','#D9FFFF','Parent',ax);
xlabel(ax,'powerLevels')
ylabel(ax,'temperatures')
zlabel(ax,'values')
grid(ax,'on')

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

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by