matlab 2014a 和VS2015编译过程出现无法打开文件“ucrt.lib”的问题

今天在用matlab 2014a 和VS2015编译过程出现无法打开文件“ucrt.lib”的问题,发现网上有些帖子来解决这个问题,我试一下,都没有成功,后来用一个最简单的方式,先在电脑上安装Windows Kits,然后找到包含ucrt.lib的文件,将文件中的lib文件直接复制到你运行的matlab程序的个目录下即可!
#include <graphics.h> #include <conio.h> #include <cmath> #include <vector> const int WIDTH = 900; const int HEIGHT = 900; #define PI acos(-1.0) // 根据距离获取渐变色COLORREF getGradientColor(double distance, double maxDist, double t) { // 使用正弦函数创建动态颜色变化 double r = 128 + 127 * sin(distance * 0.01 + t); double g = 128 + 127 * sin(distance * 0.01 + t + 2 * PI / 3); double b = 128 + 127 * sin(distance * 0.01 + t + 4 * PI / 3); // 确保颜色值在0-255范围内 r = r < 0 ? 0 : (r > 255 ? 255 : r); g = g < 0 ? 0 : (g > 255 ? 255 : g); b = b < 0 ? 0 : (b > 255 ? 255 : b); return RGB(static_cast<int>(r), static_cast<int>(g), static_cast<int>(b)); } int main() { initgraph(WIDTH, HEIGHT); // 设置背景为黑色 setbkcolor(BLACK); cleardevice(); // 预计算数据 const int N = 10000; std::vector<double> x_vec(N), y_vec(N), k_vec(N), e_vec(N), d_vec(N); for (int idx = 0; idx < N; idx++) { x_vec[idx] = idx + 1; y_vec[idx] = x_vec[idx] / 235.0; k_vec[idx] = (4 + cos(y_vec[idx])) * cos(x_vec[idx] / 4); e_vec[idx] = y_vec[idx] / 8 - 20; d_vec[idx] = sqrt(k_vec[idx] * k_vec[idx] + e_vec[idx] * e_vec[idx]); } double t = 0; BeginBatchDraw(); // 主循环 while (!_kbhit()) { cleardevice(); // 计算并绘制所有点 for (int idx = 0; idx < N; idx++) { double x_val = x_vec[idx]; double y_val = y_vec[idx]; double k_val = k_vec[idx]; double e_val = e_vec[idx]; double d_val = d_vec[idx]; // 根据MATLAB代码计算qc double q = sin(k_val * 3) + sin(y_val / 19 + 9) * k_val * (6 + sin(e_val * 14 - d_val)); double c = d_val - t; // 计算点的坐标 double screenX = q * cos(d_val / 8 + t / 4) + 50 * cos(c) + 200; double screenY = q * sin(c) + d_val * 7 * sin(c / 4) + 200; screenX = screenX * WIDTH / 400; screenY = screenY * HEIGHT / 400; // 计算点到中心的距离 double centerX = WIDTH / 2.0; double centerY = HEIGHT / 2.0; double dist = sqrt(pow(screenX - centerX, 2) + pow(screenY - centerY, 2)); // 根据距离时间获取颜色 COLORREF color = getGradientColor(dist, sqrt(WIDTH * WIDTH + HEIGHT * HEIGHT) / 2, t); putpixel(static_cast<int>(screenX), static_cast<int>(screenY), color); } t += PI / 120; FlushBatchDraw(); Sleep(5); } EndBatchDraw(); closegraph(); return 0; } 重构上面的图形库 使用支持的 可通过mysys2下载的c图形库
最新发布
12-19
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值