3D plot matrices

3 次查看(过去 30 天)
Ludwig
Ludwig 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 个)

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