Reference a variable in a text portion of a live script
이전 댓글 표시
Let's say for example I have a live script that calculates the square root (or any function) of some number x and returns it as y
Is it possible for the live editor to be able to grab the value of x and y and use them as strings in the formatted text? (using sprintf or similar?)
I do not care about this within the editor itself, but it would be nice to include this with the PDF or Latex code export
Example
x = 4;
y =sqrt(x);
Output:
"The square root of x is y" ← should be replaced with "The square root of 4 is 2"
Thanks!
댓글 수: 1
Cecilia S.
2021년 9월 2일
x = 4;
y =sqrt(x);
fprintf('the square root of %g is %g',x,y)
I think that does it, it works on normal scripts too, the %g represents a numeric variable that you then call in the order they appear at the back of the function, but you can use many others, the formatting optins are here:
답변 (2개)
Oliver Kluge
2020년 3월 6일
4 개 추천
Thank you for your interest in this feature. This is something our development team is aware of and is considering.
This feedback is useful and we hope to address it in an upcoming release.
댓글 수: 6
Jex MacGregor
2020년 10월 28일
I would also really like this feature it would make the live editor much more usefull for presenting information in a format other than plots
Barbab
2021년 8월 30일
Any update about this? Was trying to do the same
x = 4;
y =sqrt(x);
fprintf('the square root of %g is %g',x,y)
I think that does it, it works on normal scripts too, the %g represents a numeric variable that you then call in the order they appear at the back of the function, but you can use many others, the formatting optins are here:
naga240
2023년 2월 28일
Any update?
Oliver Kluge
2023년 3월 15일
I'll send an update next week. Please excuse the waiting time.
Oliver Kluge
2023년 3월 20일
A beta version for
1) creating handouts in the form of interactive live scripts,
2) creating handouts in the form of non-interactive documents,
e.g., as PDF, LaTeX, HTML, or Microsoft Word handouts,
is available for MATLAB's Live Editor.
Referencing MATLAB variables is possible with interactive live scripts and non-interactive documents.
If you are interested, please visit
https://www.mathworks.com/campaigns/sla/new-live-editor-features-beta.html
Thank you.
Chris Pearce
2020년 5월 22일
0 개 추천
Yes this is a basic function if you woul like to use live editor in a meaningful way to present data.
댓글 수: 1
Cecilia S.
2021년 9월 2일
x = 4;
y =sqrt(x);
fprintf('the square root of %g is %g',x,y)
the square root of 4 is 2
I think that does it, it works on normal scripts too, the %g represents a numeric variable that you then call in the order they appear at the back of the function, but you can use many others, the formatting optins are here:
카테고리
도움말 센터 및 File Exchange에서 Whos에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!