i have a matlab code with 3 for loops, in last for loop , there is threshold based penalization. i want trace some variables in that code and compare with plot

4 次查看(过去 30 天)
respected professor.
i have code with 3 for loops. 1st for delta (which gives different plots in the same figure) 2nd for eps ( which is on x axis of figure) 3rd for Nt, giving different alpha .and in the 3rd loop pout1 and pout2 is also found which is used in threshold based penalization.
i am giving the threshold based penalization problem as screenshot as well as the figure .
i have the code for generating the figure. and i am attaching the code also.
i want to trace the value of delta, eps , Nt, alpha, pout1, pout2 and get the new alpha which is in the plot and compare these values from plot.
Thank you in advance

采纳的回答

Image Analyst
Image Analyst 2025-1-26
编辑:Image Analyst 2025-1-26
Make sure the variables you want to write out to the CSV file are all matrices (so you need to to create pout1 and put2 and index them in the loop).
ALso, after the loop, create Nt as a vector like this:
Nt = (0 : N)';
Look how you're creating this:
eps = 10^(sweepParam(iSweep)./10);
That's not right. eps is a built-in function and takes input arguments. You do not assign the built-in function to some number. You need to create your own indexed variable and index it, like
myEpsilon(iSweep) = 10^(sweepParam(iSweep)./10);
Then after the loop, call writematrix or writetable to write out all your variables.
  1 个评论
shahnaz fatima
shahnaz fatima 2025-1-27
移动:Image Analyst 2025-1-28
Thanks for the eps clarity. i will change that.
you mean i have to create indexes for all and then arrange them for csv file. i will check that .
but there is simple solution i think . i came across the diary function, >>diary('C:\Users\shahn\Desktop\element splitting\output_log.txt')
to output the display in command window to text file. but i am getting wrong values in the text file. i you can help

请先登录,再进行评论。

更多回答(1 个)

埃博拉酱
埃博拉酱 2025-1-25
If I understand you correctly, you might want to try animatedline. Use this method to keep adding new points to the line as you loop, achieving the "trace" effect you want.
  3 个评论
Image Analyst
Image Analyst 2025-1-26
Exactly what variables do you want to write out? Make sure the variables you want to write out to the CSV file are all matrices (so you need to index them in the loop), and then after the loop, call writematrix or writetable.
埃博拉酱
埃博拉酱 2025-1-27
Writing to CSV is a different question. Do you have difficulty in constructing data structure suitable for CSV or the usage of APIs related to CSV writing?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

产品


版本

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by