maximum size of a string in matlab

假如想象 提交于 2020-01-14 13:13:41

问题


I am a newbie at matlab and I am trying to solve the following scenario.

I have large strings which need to be xor'ed essentially encoded in order to get a value. I am using the following code snippet to perform the operation :

 clear;clc;
 first ='abceeeeeeeeeeeeeeeddddddddddddd';
 second='defrrrrrrrrrrrrttttttttttttuuuu';
 result=bitxor(uint8(double(first)) , uint8(double(second)));

In the code above I am hard coding the value of the strings. I was wondering if matlab defines a size limit on the strings? If someone could help me to understand this value more in terms of bytes it will be very helpful.

Thanks and Regards, Bhavya


回答1:


I don't think tere is a size limit attached to the variable, but there is certainly a limit in term of available memory which depends on your operating system and computer architecture.

For example, I run Matlab R2008b on a 32 bits Windows 7. The output of the command memory gives me:

Maximum possible array:            1128 MB (1.183e+009 bytes) *
Memory available for all arrays:   1470 MB (1.542e+009 bytes) **
Memory used by MATLAB:              294 MB (3.085e+008 bytes)
Physical Memory (RAM):             3519 MB (3.690e+009 bytes)
*  Limited by contiguous virtual address space available.
** Limited by virtual address space available.

I can create a character array of 5e8 elements before I raise an "out of memory" error, so that is 1e9 bytes, which is in agreement with the memory output.

You can check out the technical notes related to memory management on the MathWorks website:

  • Maximum Matrix Size by Platform
  • Memory Management Guide
  • Avoiding 'Out of Memory' Errors


来源:https://stackoverflow.com/questions/8892140/maximum-size-of-a-string-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!