转换MATLAB code,成C [英] Converting matlab code, into c

查看:123
本文介绍了转换MATLAB code,成C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个matlab函数读取一个大矩阵计算奇异值分解。不过,我需要在Linux系统上运行,而不需要每一个新的系统上安装MATLAB,所以我还想要把它转换成C源$ C ​​$ C。在code是真的简单:

 函数奇异(M)
加载C:\\ SOM \\ matlab.txt
[U,S,V] = SVD(MATLAB);
M = str2num(米);
U1 = U(:,1:楼(开方(M)));
V1 = V';
VT = V1(1:楼(开方(M)),:);
S1 = S(1:楼(开方(M)),1:楼(开方(M)));
matlab1 = U1 * S1 *佛蒙特州;
matlab2 = ABS(matlab1);
保存C:\\ SOM \\ matlab1.txt matlab1 -ascii
保存C:\\ SOM \\ matlab2.txt matlab2 -ascii


解决方案

您可以使用的 Matlab的codeR ,不过我劝你还是手动进行,因为某些功能是不可兑换的,而且性能也不遑多让的手动个不停了。

为使SVD手动: SVD

i have a matlab function that reads a big matrix and calculates the Singular Value Decomposition SVD. I however need to run that on a linux system without needing to install matlab on every new system, so id like to have it converted into c source code. The code is realy simple:

function singular(m)
load c:\som\matlab.txt
[U,S,V]=svd(matlab);
m = str2num(m);
U1=U(:,1:floor(sqrt(m)));
V1=V';
Vt=V1(1:floor(sqrt(m)),:);
S1=S(1:floor(sqrt(m)),1:floor(sqrt(m)));
matlab1=U1*S1*Vt;
matlab2=abs(matlab1);
save c:\som\matlab1.txt matlab1 -ascii
save c:\som\matlab2.txt matlab2 -ascii

You can use the Matlab coder, but I advise you to make it manually, because some functions are not convertible, and the performance is not much better that mading it manually.

To make svd manually: SVD

这篇关于转换MATLAB code,成C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆