我使用了一個名爲ind2patch
的函數來製作一個3D塊,其中包含三維中的一些較小的塊。每個小塊都有一個用顏色表示的值。一個典型的情節是這樣的一個:從一組3D圖創建視頻
現在我想顯示值與使用視頻,這些小塊的時間的變化(即顏色)。我有不同時刻的數據,但我只知道如何通過閱讀不同的文件在不同時間繪製圖表。有沒有辦法將情節結合到視頻中,或直接以視頻的形式繪製圖表?
這裏是我的代碼:
clear; close all; clc;
fig = figure(1);
set (fig, 'Units', 'normalized', 'Position', [0,0,1,1]);
fig_color='w'; fig_colordef='white';
cMap=jet(256);
faceAlpha1=1;
faceAlpha2=0.65;
edgeColor1='none';
edgeColor2='none';
NumBoxX=100;%box number in x direction
NumBoxY=100;%box number in y direction
NumBoxZ=5;%box number in z direction
fid = fopen('rho 20950.dat','r');
datacell = textscan(fid, '%f%f%f%f%f%f%f%f');
fclose(fid);
all_data = cell2mat(datacell);
M=zeros(NumBoxX,NumBoxY,NumBoxZ);
for i=1:NumBoxX
for j=1:NumBoxY
for k=1:NumBoxZ
num=k+NumBoxZ*(j-1)+NumBoxZ*NumBoxY*(i-1);
M(i,j,k)=all_data(num,4);
end
end
end
indPatch=1:numel(M);
[F,V,C]=ind2patch(indPatch,M,'v');
title('\sigma_{xy} in different cells','fontsize',20);
xlabel('y','fontsize',20);ylabel('x','fontsize',20); zlabel('z','fontsize',20); hold on;
set(get(gca,'xlabel'),'Position',[5 -50 30]);
set(get(gca,'ylabel'),'Position',[5 50 -15]);
set(get(gca,'zlabel'),'Position',[64 190 -60]);
patch('Faces',F,'Vertices',V,'FaceColor','flat','CData',C,'EdgeColor','k','FaceAlpha',0.5);
axis equal; view(3); axis tight; axis vis3d; grid off;
colormap(cMap); caxis([min(M(:)) max(M(:))]);
cb = colorbar;
set(get(cb,'title'),'string','Stress (MPa)','fontsize',20);
lbpos = get(cb,'title'); % get the handle of the colorbar title
%set(lbpos,'Units','data');% change Units to data
%pos = get (lbpos,'position'); % get position of the colorbar title
set(lbpos,'units','normalized','position',[0,1.04]);
MyAxes=gca;
set(MyAxes,'Units','Normalized','position',[0.05,0.1,0.8,0.8]);
zoom(1.85);
不要use'jet'如色彩表:(使用感知均勻colromaps! –
@Ander Biguri,你是說那個顏色表適用於所有具有不同值的地塊?我是新用戶,不太確定感知均勻的色彩地圖。 –
有可能成爲垃圾郵件,請使用:http://uk.mathworks.com/matlabcentral/fileexchange/51986-perceptually- uniform-colormaps。知覺上統一的色彩圖是一個更好地表示數據的色彩圖。在人的眼睛上感知一種類似的金元音。 Jet很厭倦。 –