
loglog plot ticks + getdata
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello dear community,
This question is probably more then just Matlab related but I hope it can be answered. My main aim is, to import following chart into matlab and get Atl Value (y-axis) in regards of the test signal voltage Vs.

I have a function (for example)
function [AtlValue] = Atl(Vs, Integ)
and when I cast this function with the Vs and the Integration Time, my function should tell me what is the corresponding Y-value.
So I tried different approaches here. First to plot a loglog figure and just draw the chart in this figure to save it later. However I struggled here because of the ticks. It does not work, when I add a tick starting from 0 to 0.01 and then 0.1, 1, 10, 100

Even when this would work, I do not know how to draw this chart in this mode...
My second approach was to create the lines segmented. So first from 0 to 0.01 like this:
x = logspace(0,0.01,100);
This approach also did not work quite well because it starts somehow at 1...
So my question would, if someone could give some hints and tips how I could correctly implement this chart into matlab. It is not necessary, that I do have the chart visually. It would be enough to have the data in an array.
Please let me know, if more information is needed.
Thank you very much!
Best regards, Eska
0 commentaires
Réponse acceptée
dpb
le 23 Août 2018
Modifié(e) : dpb
le 24 Août 2018
Someone manually labeled the ticks in the example plot to scale from mV to V; the axis has to be in one set of units; it doesn't matter which, choose whichever you would prefer.
y = logspace(a,b,n) generates n points between decades 10^a and 10^b so 10^0 --> 1 is exactly the starting point you asked for. 10^0.01 --> 1.023 so you generated a logarithmically-distributed vector of length 100 on the interval [1 1.023]. Moral is "read the documentation carefully!!!". :)
From a practical matter, to draw the plot you'll have to read the points off of it anyway, so you may as well just do that from the beginning and store them in the array. All you need to store is the values at the breakpoints; you can then simply interpolate in log-log space in your lookup function with interp1 to return a value given the input voltage and the short/long flag variable for which curve to use.
ADDENDUM
Just for grins...
VL=[0.005 0.030 0.15 0.3 1 2 9 20].';
VS=[0.005 0.050 0.15 0.3 1 2 20].';
AL=[0.6 0.1 0.1 0.05 0.05 0.1 0.1 0.15].';
AS=[2 0.2 0.2 0.1 0.1 0.15 0.15].';
hL=loglog(VL,AL,'k--','LineWidth',2);
hold on
hS=loglog(VS,AS,'k-','LineWidth',2);
xlim([0.001 30]); ylim([0.01 3])
grid on
hAx=gca;
xtk=[0.005 0.01 0.02 0.05 0.1 0.2 0.5 1 2 5 10 20];
hAx.XTick=xtk;
xtklab=[strtrim(cellstr(num2str(1000*xtk(xtk<1).','%dm'))); ...
strtrim(cellstr(num2str(xtk(xtk>=1).')))];
hAx.XTickLabel=xtklab;
ytk=[0.01 0.02 0.05 0.1 0.15 0.2 0.5 1 1.5 2];
hAx.YTick=ytk;
ylabel('At1')
xlabel('Test signal voltage')
hTS=text(VS(1),AS(1),['INTEG TIME' char(10) 'SHORT'],'HorizontalAlignment','right');
hTL=text(VL(1),AL(1),['MEDIUM' char(10) '& LONG'],'HorizontalAlignment','right');
yields

after pulling/pushing shape of the figure window around to approximate the form factor of the above which is reasonable representation although I made no attempt to really tell what the breakpoint values really ought to be if not rounded.
function A = Atl(Vs, Integ)
VL=[0.005 0.030 0.15 0.3 1 2 9 20].';
AL=[0.6 0.1 0.1 0.05 0.05 0.1 0.1 0.15].';
VS=[0.005 0.050 0.15 0.3 1 2 20].';
AS=[2 0.2 0.2 0.1 0.1 0.15 0.15].';
if ~all(iswithin(Vs,0.005,20)), error('Input Vs outside 5mV to 20V (in V)'),end
if any(strncmpi(Integ,{'med','lon'},3))
A=interp1(log10(VL),log10(AL),log10(Vs));
elseif strncmpi(Integ,{'sho'},3)
A=interp1(log10(VS),log10(AS),log10(Vs));
else
error('unrecognized keyword for Integ')
end
A=10.^A;
end
function flg=iswithin(x,lo,hi)
% returns T for values within range of input
% SYNTAX:
% [log] = iswithin(x,lo,hi)
% returns T for x between lo and hi values, inclusive
%
% dpb 1990 Jul
flg= (x>=lo) & (x<=hi);
end
2 commentaires
dpb
le 24 Août 2018
Was interesting to do the plot; hadn't ever done the specific axis labels so thought worth illustrating...thought I had fixed the copy/paste error, thanks...
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Labels and Styling dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!