- Initialize “sum1” and “sum2” as 0
- Initialize a value of “N”
- Start a for loop from 1 to “N”
- Update sum1 by incrementing it with “10^(k-1)”
- After the for loop, update “sum2” as “0.1*10^N” as using for loop here would increase the time complexity exponentially.
- Finally take the difference of “sum1” and “sum2”.
Using summation and series to create a function to analyse and find error
1 次查看(过去 30 天)
显示 更早的评论
I have a series of 10^(N-1) minus a summation of k=1 to 10^(N) of 0.1. I havn't worked with sums and series in a while and was wondering how to get exact value of N and what ever information you could give on composing the function with a for loop. I think that might help me figure out the function I need to create in my project. I have seen a lot of information on summations and how to put into a script in matlab, but I have found nothing on how I can do this with a power of N on the upper limit. Thankyou in advance. Any information you can provide would be helpful. P.S. Yes, I have looked up how to do summations in matlab and have not yet found how to do this particular problem. I know I need to use a for loop.
0 个评论
回答(1 个)
Binaya
2023-10-19
Hi Richard,
Based on your description, you would like to develop a MATLAB code using for loop for the series “10^(N-1)” and a summation of “k=1 to 10^(N)” of “0.1”, and take its difference.
Please find the below algorithm as a possible solution to your query:
Please refer to the below Mathworks documentation for more reference:
I hope this helps.
Regards
Binaya
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!