Hi
Here is the code I used to get the coloured blocks. I get my data from a simulation I run on MicroCap12.
clear
clc
writerObj = VideoWriter('C:\Users\WINDOWS11\Documents\MATLAB\EExp100100','MPEG-4');%Name of video file
open(writerObj);
fig1 = figure(1);
load EExp100100.TNO %Read in the file generated by Microcap 12 -No headers
d1 = EExp100100;
timestamp = d1(:,1);
d1(:,1)=[];%Remove time
rws=100; %Get this number from the Microcap 12 netlist
cols=100; %Get this number from the Microcap 12 netlist
s=size(d1);
d1ct=1;
%I use the same block coordinates I used to set up the MicroCap12 simulation
ind1a = (20:80);
ind1b = (1:40);
Z(ind1a,ind1b) = 0;
ind2a = (20:80);
ind2b = (60:100);
Z(ind2a,ind2b) = 0;
for k = 1:s(1)
for j=1:rws
for i=1:cols
Z(j,i)=d1(k,d1ct);
d1ct=d1ct+1;
end
end
d1ct=1;
x=1:1:rws;
xx=1:1:rws;%put in an increment for spline command
for p=1:cols
y=Z(:,p);
yy(:,p)=spline(x,y,xx);
end
syy=size(yy);
x=1:1:cols;
xx=1:1:cols; %put in an increment for spline command
for p=1:syy(1)
y=yy(p,:);
Zz(p,:)=spline(x,y,xx);
end
%s2=size(Zz);
%mztb=zeros(1,s2(2)+2);
%sidez=zeros(s2(1),1);
%Zc=[mztb;sidez Zz sidez;mztb];%put some 0's around the data
%[X,Y] = meshgrid(1:1:s2(2)+2, 1:1:s2(1)+2);
[X,Y] = meshgrid(1:1:100, 1:1:100);
%mesh(X,Y,Zc);
mesh(X,Y,Zz)
colormap(bone)
%colormap(sky)
view([-50 70])
title('100 by 100 grid (spline = 1)')
xlabel('X')
ylabel('Y')
txt = ['Time: ' num2str(timestamp(k,1)) ' secs'];
text(-15,-5,txt)
%axis([1 s2(2)+2 1 s2(1)+2 -2 2])
axis([1 100 1 100 -2 2])
hold on
m1 = mesh(X(ind1a,ind1b),Y(ind1a,ind1b),Z(ind1a,ind1b));
set(m1,'Facecolor','r');
m2 = mesh(X(ind2a,ind2b),Y(ind2a,ind2b),Z(ind2a,ind2b));
set(m2,'Facecolor','r');
view(-50,70)
hold off
F=getframe(fig1);
%write the current frame to the writer object
writeVideo(writerObj,F)
end
%Close the writer object. File appers in current folder
close(writerObj);
disp('Video File Written')