Bonjour à tous,

J'ai un problème dans un code de diffraction écrit en Matlab, concernant apparemment la fonction 'imagesc', mais je ne vois pas trop ce qui cloche...?

Voici la partie de code concernée :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 
clear
N=300;
format compact
clf
hold off
start=cputime;
x=[0:.1:pi];  
z=zeros(size(x));
StartPLD=6.2;
EndPLD=6.35;
Increment=.002;
intensity=zeros(1,2000);
OPL=zeros(1,2000);
k=1;
figure(2);clf;
for pld=StartPLD:Increment:EndPLD,  
  z=zeros(size(x));
  a=0;
  for j=1:N, 
     y=sin(3.*x+a);
     z=z+y;   
     a=a+pld;
  end
  intensity(k)=sum(z.*z);  
  OPL(k)=pld./(2*pi);
  imagesc(OPL(1:k-1),intensity(1:k-1))
  ylabel('Observed irradiance  (Mean-square of sum of all reflections)')
  xlabel('Pathlength difference between adjacent grooves, in wavelengths')
  title(['First-order diffraction pattern for grating with '  num2str(N)  ' grooves.'])
 
  k=k+1;
end
hold off
figure(2)
ElapsedTime=cputime-start
figure(3)
plot(OPL(end-1),intensity(end-1))
Merci pour vos suggestions.