循环中的迭代次数(Number of iterations in a loop)

为什么以下代码

for a=1:5:100
    a = a+ 1;
end

迭代20次?

a每次迭代增加5,但在实际循环中也增加1。 99/6 = 16.5或17次迭代,为什么它会做20次?

感谢您帮助了解for循环功能的工作原理。


Why does the following code

for a=1:5:100
    a = a+ 1;
end

iterate 20 times?

a goes up by 5 every iteration, but also goes up by 1 in the actual loop. 99/6 = 16.5 or 17 iterations, so why does it do 20?

Thanks for any help understanding how the for loop function works.


原文:https://stackoverflow.com/questions/23133396
2022-01-19 07:01

满意答案

大部分真正大规模的网络媒体资源都使用分布式键值存储。 也就是说,3500万是大的,但并不那么大。 对于大多数现代数据库,您主要的两个扩展问题应该是吞吐量,并且当没有单个盒子可以包含整个数据库时会发生什么。 对于您选择使用的任何数据库,这两个问题都可以在一定程度上得到解决。 (缓存,复制,分片等)

直到你不能再使用MySQL。 那时,无论如何你都应该在面团中滚动,现在你有一个非常理想的问题。


Most of the truly large scale web properties use a distributed key-value store. That said, 35 million is large, but not that large. With most modern databases, your main two scaling worries should be throughput and what happens when no single box can contain your entire database anymore. And both of these problems can be solved to some degree for any database you choose to use. (Caching, replication, sharding, etc.)

Use MySQL until you can't anymore. At that point, you ought to be rolling in dough anyways and you now have a very desirable problem.

相关问答

更多

什么是“大数据库”?(Just what is 'A big database'?)

没有一个小数据库变成中等或中等数据库变大的阈值。 一般来说,当我听到这些条款时,我认为存储的记录总数是特定数量级的。 小:10个5以下的记录。 中等:10 5至10 7个记录。 大:10 7至10 9条记录。 非常大:10 9个或更多的记录数。 正如海报le dorfier所建议的,你也可以根据每种数据库的属性来考虑它。 这样分类,我会说: 小:性能不是问题。 您的查询运行正常,无需进行任何特殊优化。 使用前端增强功能(如索引)时,您只会看到边际性能差异。 媒介:您的数据库可能有一名或多名员工被分...

大数据数据库(Big Data Database)

这是一个扩展的评论,而不是一个全面的答案...... 108000*3500大小的数据集并不是真正的大数据 ,除非您省略了GB等单位。 如果它只有108000*3500字节,那只有3GB加上变化。 您提到的任何技术都可以轻松应对。 我认为你应该根据哪种方法来加速你的发展而不是加快你的执行速度来做出你的选择。 但是如果你想要进一步考虑的话,我建议: SciDB 拉斯达曼 ,和 莫奈DB 所有这些在学术大数据社区都有一定的吸引力,并且也开始在该社区之外使用。 This is an extended c...

Django和直接的数据库操作(Django and direct database manipulation)

我有同样的问题试试这个: def save(self, force_insert=False, force_update=False, using=None, update_fields=None): self._meta.local_fields = [f for f in self._meta.local_fields if f.name not in ('your_field')] super(Atlantis, self).save(force_insert, force_upda...

什么数据库用于大数据存储和操作?(What database to use for big data storage and manipulation?)

大部分真正大规模的网络媒体资源都使用分布式键值存储。 也就是说,3500万是大的,但并不那么大。 对于大多数现代数据库,您主要的两个扩展问题应该是吞吐量,并且当没有单个盒子可以包含整个数据库时会发生什么。 对于您选择使用的任何数据库,这两个问题都可以在一定程度上得到解决。 (缓存,复制,分片等) 直到你不能再使用MySQL。 那时,无论如何你都应该在面团中滚动,现在你有一个非常理想的问题。 Most of the truly large scale web properties use a dis...

数据如何存储在数据库中?(How is data stored in a database?)

将数据存储在数据库中不是主要问题。 相反,问题在于查看或操纵存储的数据。 例如,想要访问数据的频率,您想要何时访问数据,您想访问哪些数据等问题才能得到解答。 如果您确信您的数据处理细节,那么您可以相应地设计表并选择合适的技术来操作数据。 您可以参考数据库管理系统上的任何书籍。 高级DBMS教程 Storing data in a database is not a major problem. Instead, the problems lies in viewing or manipulatin...

Linq和.Count大数据库(Linq and .Count big database)

你最好这样做: var query = db.books.AsQueryable(); if (market_id!=0) query = query.Where(x=>x.market_id==market_id); if (name!=null) query = query.Where(x=>x.name.StartsWith(name)); count = query.Count(); data = query .OrderBy(x=>x.id) .Skip(param...

MySQL海量数据操作处理(MySQL Massive Data Manipulation Processing)

通过单个查询可以识别现有数据的状态变化,但(正如您所发现的)非常昂贵。 我建议您将每个状态更改存储在缓存中。 正如@Fluffeh解释的那样 ,如果使用合适的索引,从现有表中查找最新状态将不会非常昂贵; 所以触发方法应该是非常合理的。 因此: 定义合适的索引(如果它尚不存在): ALTER TABLE existing_table ADD INDEX (register_id, timestamp); 为缓存创建一个表(并可选择设置用户权限,以便您的应用程序无法直接修改它): CREATE TA...

如何存储大数据用于计算?(How to store big data for use in computation?)

如果您正在为大量数据寻找灵活的数据库, MongoDB可能是您正在寻找的技术。 MongoDB属于NoSQL数据库系统的家族,它是: 基于类似JSON的文档 即使有大量数据也具有高性能 无架构 文件为基础 开源 可查询 可转位 它允许您以非常灵活的方式修改您的模式,非常容易插入数据(1.),修改数据及其结构(2.),比XML(3.)和基于JSON的更快有效存储(4.)。 If you're looking for a flexible database for a large amount of ...

Python大数据矩阵操作(Python Big Data Matrix manipulation)

虽然我同意评论,唯一可以确定的方法是为自己编写内容,但有一些指导原则可以帮助您在第一次尝试时编写高效的numpy代码。 以下是您的问题的一些建议: 创建新numpy数组的开销是加/加的成本的1000倍,因此方法2应该是低效的,因为每次调用np.dot都会创建一个数组,但只执行27次加法。 如果你在python中有一个缓慢的for循环,如果可能的话,在最左边的轴上做(对于C有序数组)。 很难有效地编写非常通用的N维代码,因此我的猜测是,一系列简单的numpy调用将比np.einsum更有效。 尝试C...

数据库操作(Database manipulation)

最好的方法是在所有字段中保留从数据库中检索的数据并更新所有字段。 如果用户更改了该值,则会将其更新为新值。 否则它将保持相同的旧值。 假设您从数据库中检索了所有值,并且单击了编辑按钮,它们是可编辑的(文本框),其中已存在旧值。 然后写一个像这样的查询 update contacts set title =@title, firstName=@firstName, middleName=@middleName, lastName=@lastName where contactID=@ContactI...

相关文章

更多

She’s Not Carrying A Handbag

Gao Yuanyuan from after 2005 drama " world fir ...

Spark - A Fault-Tolerant Abstraction for In-Memory Cluster Computing

http://spark-project.org/ 项目首页 http://shark.cs.berk ...

How to Start a Business in 10 Days

With an executive staffing venture about to open, a ...

Create a Bootable MicroSD Card

http://gumstix.org/create-a-bootable-microsd-card.h ...

Drupal Forums instead of phpBB or vBulletin: A casestudy

5th Jan, 10 Drupal drupal advanced forum drupa ...

Python内建函数(A)

abs(x) 说明:abs(x)返回x的绝对值,如果参数是复数,则返回复数的模; 参数x:整 ...

每日英语:Philippine Chapel Becomes a Medical Center

In the darkest moments of the killer storm that rip ...

Become a Master Designer: Rule Three: Contrast, Contrast, Contrast

Part Three of Seven Easy Principles to Becoming a M ...

Securing Solr on Tomcat access using a user account

Open [Tomcat install dir]\tomcat-users.xmlfor editi ...

Stack Overflow Architecture Update - Now At 95 Million Page Views A Month

A lot has happened since my first article on theSta ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本