You are on page 1of 2

Animatingimagescplots

I'mtryingtoanimateanimagescplot
usingrefreshdata,butwith
AskedbyJameson10Jun2011
theseplots,thereisno
'CDataSource'propertywith
5views(last30days)
whichIcanlinkthedataI
wouldliketochangeandthenewvalues.Isthereawaytolinkdatasourcesinimagescplots?Iknowthatthereis
a'CData'propertybutthisdoesn'tseemtowork(atleastinthewayI'vetried).
Icurrentlyhaveanarray,plotitusingimagesc,andundertheholdcondition,includeaforloopwhichincludesthe
varyingdataaswellastherefreshdata,pauseanddrawnowcommands.
Thisisjustmeanttobeasimpleanimationdisplayingasimpleconcept,soaslongasIcanjustupdatethisdata
thatisfine.Anyothermethodideasforanimatingarrayswouldbegreatlyappreciated.
*Note:Ihaveusedtherefreshdatamethodforanimatingplotsinthepast,onlyitwasusingtheplotcommand(not
imagesc)andIwasusing2datasources.

2Comments

JanSimonon10Jun2011

Whatare"thevaryingdata"?Itwouldbehelpfulifyoupostthecode,such
thatwecanaddthechangesanddonothavetocreatethewholecode
fromscratch.
Jameson10Jun2011

Myapologies,wasn'tthinking.Here'swhatIhavesofar.It'sthebeginnings
ofananimationshowingtheamplitudeandphasebehaviorincavityring
downspectroscopy,sopleaseexcusetheoddarray.
functionCavity(f,phi,reps)
%CavitywrittenbyJamesMester
%Thisfunctionshowstheintensitymodulationoftheincidentbeam,
%cavityresonanceandtransmittedbeamincavityringdownspectroscopy.
%VARIABLES:
%ffrequency(Hz)
%phiphasedifference(degrees)
%repsrepetitions(periodsoff)
%defineangularfrequency
w=2*pi*f
%definephaseinradians
phir=phi*pi/180
%defineperiod
T=1/f
%definetimevector
t=0:.001:(reps*T)
%buildcavityarray
cavity=zeros(1001,1001)
cavity(:,:)=1
coeff=100/(500^2)
forx=500:500
y(x+501)=coeff*x^2
end
fori=1:25
forx=1:1001
cavity(x,200+i+floor(y(x)))=0

cavity(x,800iceil(y(x)))=0
end
end
forx=251:750
cavity(x,(225+ceil(y(x))):(775ceil(y(x))))=0.2
end
forx=351:650
cavity(x,1:(201+floor(y(x))))=0.4
end
forx=401:600
cavity(x,(800ceil(y(x))):1001)=0.6
end
%plotfigure
figure(1)
%holdon
fig=imagesc(cavity)
colormap(bone)
set(fig,'CData',cavity)
%linkdataon
%forloopthatvariesintensityvalues
fori=1:length(t)
forx=351:650
cavity(x,1:(201+floor(y(x))))=0.3*cos(w*t(i))+0.7
end
forx=251:750
cavity(x,(225+ceil(y(x))):(775ceil(y(x))))=0.4*cos(w*t(i)phir)+0.6
end
forx=401:600
cavity(x,(800ceil(y(x))):1001)=0.2*cos(w*t(i)phir)+0.8
end
pause(0.01)
refreshdata(fig,'caller')
drawnow
end
%holdoff
end

You might also like