Graph tiltle with multiple variables over 2 lines

1 vue (au cours des 30 derniers jours)
Franc
Franc le 27 Avr 2019
Modifié(e) : Franc le 28 Avr 2019
I Have been tryint to make the variables contained in this title append over two maybe three lines, following the use of {} brackets. But so far it returns 3 per lines per num2str. Could anyone help point appropriate corrections to obtain 2 maybe three lines.
thanks
title({'Request dur= ' num2str(timeseriesMatPurgeRequest{II}{X}.time(end)),'s, Request Dist = ' num2str(timeseriesMatPurgeRequestvalues(1)),'km', 'NOx eff = ' num2str(((timeseriesMatPurgeRequestvalues(1)-timeseriesMatPurgeRequest{II}{X}.ExM_mStrNOx_ExEle.signals.values(end))/timeseriesMat.values(1))*100) '%, Dilution = ' num2str(((timeseriesMatPurgeRequest.values(1)-timeseriesMatPurgeRequest{II}{X}.elomm_w_fio_out_01.signals.values(end))/timeseriesMatPurge.values(1))*100) '%','AcvRul = ' num2str(timeseriesMatPurgeRequest.values(1)) ', Total Rich Time = ' num2str(sum(mode(diff(timeseries.time))*numel(find(timeseriesMat.values<1)))) 's', 'NOx Remove Rate = ' num2str(((timeseriesMatvalues(1)-timeseriesMat.values(end))/(sum(mode(diff(timeseriesMatPurge.time))*numel(find(timeseriesMat.values<1))))))'})

Réponse acceptée

Geoff Hayes
Geoff Hayes le 27 Avr 2019
Franc - try using sprintf to create one or more lines that you can use in your title. For example,
myTitle = sprintf('first row has integer: %d\nsecond row has float: %f\n', 42, pi);
title(myTitle);
Note how you do not have to convert any of your numbers into strings (the '\n' is used to indicate a new line). You may want to use local variables for the calculated values rather than trying to do them all on one line of code. i.e.
totalRichTime = sum(mode(diff(timeseries.time))*numel(find(timeseriesMat.values<1)));
duration = timeseriesMatPurgeRequest{II}{X}.time(end);
myTitle = sprintf('duration = %fs\ntotal rich time = %fs', duration, totalRichTime);
or something similar.
  9 commentaires
Walter Roberson
Walter Roberson le 28 Avr 2019
With the (end) indexing at the end of timeseriesMatPurgeRequest etc., then Requestdur would have to be a scalar. If II was non-scalar or X is non scalar or ATSys_noATSysRgnReq is a non-scalar structure, then you would have received a runtime error about attempting to index improperly. The only way you could get Requestdur as a vector there without significant changes to the code is if you omitted the (end) indexing.
Franc
Franc le 28 Avr 2019
Modifié(e) : Franc le 28 Avr 2019
Geoff/Walter, I was reading the documentation a bit more i realised I could use [ ] within the { } to partition the code and then using ; between the [ ] to add another line.
So really appreciate your helping me think through it. Sample added.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by