help with program that doesn't plot

1 view (last 30 days)
Karla
Karla on 5 Sep 2014
Edited: dpb on 5 Sep 2014
I have this program that doesn't plot, but is taken from another one that works perfeclty. Can you help me please?
%%%function A1pos = TestStatistic
function ne(Isource,b)
function A1pos = DegradationStatistic
nombre_archivo=['RFHR018_DegTest_D_ch1_000.dat']; %Defino una matriz con nombres que varian en numeros, por eso uso num2str(w), w contador
fid = fopen(nombre_archivo,'r'); %Abre cada componente del vector nombre_archivo
Datar=textscan(fid,'%s %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %s %s %f %f %4s %f %f %s %s %s %f %f %f %f %f %f %f %s %s ','headerlines',14); %Escaneo el texto sin contar los headerlines, encabezados
Datar(:); % Matriz con las columnas escaneadas
Datar;
%%%%%%%%%%%On va donner les valeurs a les columnes%%%%%%%%%%%
Rmin=Datar{18}; %Resistencia Minima
Rmax=Datar{19}; %Resistencia Maxima
Name=Datar{31}; %Name of device
TMR=(100*(Rmax-Rmin)./Rmin); %TMR of each Device
Vmin=Datar{15}; %Voltage Minima
Vmax=Datar{16}; %Voltage Maximo
Isource=Datar{25}; %I from the source
TMR(:);
%b=0.050000;
%%%%%%%%%%%Separer les devices par X1 X2 %%%%%%%%%%%
%%A
for k=1:numel(Isource)
%for Isource=0:9
if Isource==0.050000
A1pos(k,1)= 1;
else
A1pos(k,1)=0;
end
if Isource>0.050000
A1pos(k,2)= 1;
else
A1pos(k,2)=0;
end
%end
%///////////plot///////////////
for i=1:2
Isource{i}=Isource.*A1pos(:,i);
TMR1{i}=TMR.*A1pos(:,i);
subplot(2,1,i)
plot(Isource{i},TMR1{i},'r'); %Grafico las columnas
axis([0 8 0 100])
ylabel('TMR(%)','fontsize',8); %eje de x
xlabel('Isource(mA)','fontsize',8);
end
%%%%%%%%%TITULO
[ax4,h1]=suplabel(['1 2 '] ,'y');
[ax4,h2]=suplabel(['1 2'] ,'x');
[ax4,h3]=suplabel(['TMR vs Isource'] ,'t');
set(h1,'FontSize',20)
set(h2,'FontSize',20)
set(h3,'FontSize',35)
%///////////Enregistrer///////////////
graf=['TMR_vs_Isource.png']; %nombre de los graficos en matriz
saveas(gcf,num2str(graf)); %graba los graficos con su nombre
figure;
close(gcf);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fclose(fid);
end
  4 Comments
Guillaume
Guillaume on 5 Sep 2014
Edited: Guillaume on 5 Sep 2014
Slight correction to dpb comment, the file should be named DegradationStatistics.m as that's the name of the function. A1pos is the return value.
Matlab normally warns about wrongly named files and offer to rename them for you.
As others have said, something more descriptive than 'it doesn't work' would get you more help. Also have you tried to step through your function with the debugger to see what's it doing?
dpb
dpb on 5 Sep 2014
Good catch, Guillaume, just glanced up and typed the first thing I saw... :) Fixed in the posting...

Sign in to comment.

Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!