Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
Hello,
I am trying to control the output of the trace() function for debugging.
Ideally I will want something like the fprintf function of several programming language to control the characters that the output displays.
It becomes really cumbersome to read the output if the vectors are not aligned as for instance
What I would like
Iteration 1
vec1_vector(3) [1.0000e-06, 0.0000e00 , 0.0000e00 ] __vec2 vector(3) [0.0000e00 , 0.0000e00 , 0.0000e00 ]
Iteration 2
vec1_vector(3) [1.6667e-06, 0.0000e00 , 1.3413e-02] __vec2 vector(3) [0.0000e00 , 1.3413e-01, 1.3413e-01]
Iteration 3
vec1_vector(3) [1.6667e-06, 2.4513e-01, 1.3413e-02] __vec2 vector(3) [2.4245e-01, 1.3413e-01, 1.3413e-01]
What I am getting
Iteration 1
vec1_vector(3) [1e-06, 0, 0] __vec2 vector(3) [0, 0, 0]
Iteration 2
vec1_vector(3) [1.16666666666667e-06, 0, 0.013413413] __vec2 vector(3) [0, 0.13413, 0.13413]
Iteration 3
vec1_vector(3) [1.16666666666667e-06, 0.24513435635647, 0.013413413] __vec2 vector(3) [0.2424542, 0.134113513, 0.13413]
Solved! Go to Solution.
I was not 100% sure about how to implement the formats and use your function, but it gave me an idea, which I am uploading just in case someone can benefit form it.
I did a "n2sd(num,sigD)" function that outputs a string with sigD significant digits and the power 10 term. Then I use
trace({0},n2sd(variable,3)) to plot with the desired length in the debbug window. It has some rounding errors and only scalars can be inputs, but for me it will do the trick.
Try if the following helps:
set the global output format (select nothing on the sheet and then choose menu item Format=>Result...) to engineering with e.g. 5 decimals and show trailing zero's and set the exponential threshold to 0.
Success!
Luc
Hi Luc,
It changed the format of the results in the sheet but not in the debug window.
Thank you for the quick reply, though.
Then I see no other option than that you create your own printf() function and use that as the first and only argument to the trace() function.
The functionality of printf() would be the same as what trace does: creating a string with the embedded values of any additional parameters supplied, but with more control over the output. That's quite a task.
Success!
Luc
This might get you going.
All you need to do is:
- Define format types (that you supply as the 3rd parameter to printf(), and that printf() uses to call format().
- Define the function format() which uses a value, and the format type, to produce a string.
(As you can see, I've taken the lazy route, just using num2str()...)
Success!
Luc
Thank you I will give it a try on the weekend
I was not 100% sure about how to implement the formats and use your function, but it gave me an idea, which I am uploading just in case someone can benefit form it.
I did a "n2sd(num,sigD)" function that outputs a string with sigD significant digits and the power 10 term. Then I use
trace({0},n2sd(variable,3)) to plot with the desired length in the debbug window. It has some rounding errors and only scalars can be inputs, but for me it will do the trick.
Would this help?
Success!
Luc
P.S. Corrected> Now properly rounds the number.