简体   繁体   中英

plotting multiple lines with text at end of line in matlab

I have some matlab code I have created for plotting multiple lines in the plot. However it does not seem to plot the text at the end of the line like I was hoping for. Does anyone have an idea of a way to make easier and why it might not be working.

format long;
options = optimset('TolFun',1e-12);
vfb = -0.9;
fT= 0.026;
fF = 0.4591431;
gamma = 0.2377589;
datafile = fopen('quiz3p2bresults.text','w');
if datafile == -1
    error('Error opening data file!');
end


fprintf(datafile, '%s\t %s\n', 'Vgb', 'PSIL')
vgb = 1:0.5:2;
vgb = vgb';
vdb = 0:0.1:1.5;
vdb = repmat(vdb,3,1);
eqn = @(psiL) (vgb-vfb-gamma*(sqrt((psiL-vdb)/fT)));
result = fsolve(eqn,vgb,options);
plot(vdb,result(1,:),'r',vdb,result(2,:),'y',vdb,result(3,:),'g');
text(max(vdb), max(result), num2str(vgb));


fclose(datafile);

Try

text(max(vdb), result( : , max(size(result)) ), num2str(vgb));

You might also want to change the plot to

plot(vdb(1,:),result(1,:), ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM