![]() |
如何将C#代码转换为MATLAB?
我有这个C#代码,我正在尝试将其转换为MATLAB代码。
float randomFloat() { return (float)rand() / (float)RAND_MAX; } int calculateOutput(float weights[], float x, float y) { float sum = x * weights[0] + y * weights[1] + weights[2]; return (sum >= 0) ? 1 : -1; } 我认为我们不能在MATLAB中使用float和int 。如何更改代码? [B]回答:[/B] 第一个很简单: rand() 第二个函数可以写成: if ( [xy 1]*w(:) >=0 ) result = 1; else result = -1; end [url=https://stackoverflow.com/questions/3439286]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 01:04。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.