3D plot matrices
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ludwig
el 6 de Jun. de 2024
Comentada: Matlab Pro
el 6 de Jun. de 2024
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.
0 comentarios
Respuesta aceptada
Mathieu NOE
el 6 de Jun. de 2024
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');
Más respuestas (1)
Matlab Pro
el 6 de Jun. de 2024
Hi @Ludwig
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 comentario
Matlab Pro
el 6 de Jun. de 2024
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')
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!