C++ 快速实现 Matlab 代码:Y_Image=(-400:tho_R:400); X_Image=(-400:tho_R:400);
在 C++ 中,可以使用循环来实现这个功能。以下是一个示例代码:
#include <iostream>
#include <vector>
int main() {
int tho_R = 10; // 设置 tho_R 的值
std::vector<int> Y_Image;
std::vector<int> X_Image;
// 初始化 Y_Image
for (int i = -400; i <= 400; i += tho_R) {
Y_Image.push_back(i);
}
// 使用 Y_Image 的值初始化 X_Image
X_Image = Y_Image;
// 输出 X_Image 的值
for (int i = 0; i < X_Image.size(); i++) {
std::cout << X_Image[i] << ' ';
}
return 0;
}
上述代码使用了std::vector来存储 Y_Image 和 X_Image 的值,并使用循环初始化它们。最后,通过循环输出了 X_Image 的值。请注意,这里我们假设 tho_R 的值为10,你可以根据实际情况进行调整。
原文地址: https://www.cveoy.top/t/topic/pgdk 著作权归作者所有。请勿转载和采集!