How to print symbolic representation of [4^1+1 4^2+1 4^3+1] rather than the actual numerical output?
1 次查看(过去 30 天)
显示 更早的评论
I would like to add a line of texts like "points = 4^1+1 4^2+1 4^3+1" instead of "points = 5 17 65" to chart.
The current content of my code to print "points = 5 17 65" is as following:
for i = 1:3
n = 4^i + 1;
%{
do something with numeric values of n and i (i.e., i = 1, 2, 3)
%}
% Storing "number of points" in vector 'point'
point(i) = n;
end
disp(['Grid points = ' sprintf('%d ', point)])
Note that I do need the numerical values of n and i (i.e., i = 1, 2, 3 for n = 4^i + 1) to do some computations.
I found
syms i
may be appropriate for my intended use, but cannot figure out how to exactly apply it into my for-loop.
Please help me to figure out, any suggestions will be very appreciated!
Thanks!
0 个评论
采纳的回答
Ameer Hamza
2020-5-17
编辑:Ameer Hamza
2020-5-17
point = 1:3;
disp(['Grid points = ' sprintf('4^%d ', point)])
Result
Grid points = 4^1 4^2 4^3
2 个评论
Ameer Hamza
2020-5-18
The syntax is not correct, according to MATLAB. But I didn't understand what you are trying to do here. Can you explain with an image what where you want to write the text()?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!