2013-01-01 33 views
3

如何使用Matlab获得以下硬件属性?如何获得处理器和硬盘制造序列号和ID?

  • 母板制造序列号
  • 处理器ID
  • 处理器制造序列号
  • 硬盘编号
  • 硬盘制造序列号

而没有任何功能或类负责用于检测其他机器硬件组件属性的属性?

我知道它可以使用系统或控制台命令完成,但我不知道如何。不过,我更喜欢两种方式,一种是使用Windows控制台命令的方式,另一种是不使用它的方式。

+2

我建议看看[这个工具]的实现(http://www.mathworks.com/matlabcentral/fileexchange/33155-cpu-info/content/cpuinfo.m)...也许它可以帮助。 –

+0

这是有用的代码,谢谢。 –

回答

9

这是一种利用控制台命令从MATLAB得到硬盘序列号:

%// Get hard disk serial using windows console command 
cmd   = 'wmic diskdrive get SerialNumber'; 
[~, result] = system(cmd); 
%// Extract first hard disk serial number 
fields  = textscan(result, '%s', 'Delimiter', '\n'); 
fields  = strtrim(fields{1}); 
serialNo = fields{2}; 

同为处理器ID:

%// Get processor id using windows console command 
cmd   = 'wmic cpu get ProcessorId'; 
[~, result] = system(cmd);  
%// Extract first processor id 
fields  = textscan(result, '%s', 'Delimiter', '\n'); 
fields  = strtrim(fields{1}); 
processorId = fields{2}; 

这是所有关于使用控制台命令wmic + [hardware name] + get + [attributename] 如果您想知道某些设备可用的全部属性,您可以在命令中使用get witho UT命名任何属性,例如:

command = 'wmic csproduct get' 

,将让你的机器的所有可用的属性,作为一个产品和它的值。

+1

+1:我没有时间自己去尝试,但我有感觉WMI会是正确的方向:) –

+1

你的链接真的很有帮助,非常感谢,你已经解决了这个问题:D。 –

+0

很高兴帮助。实际上它是那个真正解决它的工具的制造者:) ** P.S:**我建议你将自己的答案标记为已接受。 –