MATLAB左下角一直显示“初始化”,输入计算显示“正忙”

绕过许多坑,亲测有效

在win10电脑日常更新之后,以往正常打开的matlab,现在右下角显示“初始化”,输入数据显示“正忙”,查了好多资料,例如:修改系统环境变量、右击matlab属性直指许可证位置,这些都是没用的!!

只需要很简单的办法:只需要把安装matlab的那个文件夹改个名字就行了,例如,我的安装位置:D:\AAAmastersoftware\matlab\MATLABweizhi,我们只需要将MATLABweizhi多加一个下划线,即 D:\AAAmastersoftware\matlab\MATLABweizhi_

然后将桌面现有的matlab快捷图标删除,接着打开安装目录下的bin文件,创建一个快捷方式,再次打开就可以正常使用。

 

  • 37
    点赞
  • 36
    收藏
    觉得还不错? 一键收藏
  • 21
    评论
好的,这是一个更加复杂的问题。我们需要考虑障碍物随时间的移动,以及如何实时更新路径。以下是一个示例代码,其中我们使用了A*算法来进行路径规划。 ```matlab % 创建地图和障碍物 map = zeros(100, 100); obstacle1 = insertShape(map, 'FilledCircle', [30 30 10], 'Color', 'white'); obstacle2 = insertShape(map, 'FilledCircle', [70 70 20], 'Color', 'white'); obstacle3 = insertShape(map, 'FilledCircle', [50 80 15], 'Color', 'white'); obstacles = obstacle1 + obstacle2 + obstacle3; % 显示地图和障碍物 figure; imshow(obstacles); % 定义起点和终点 startPoint = [1, 1]; endPoint = [100, 100]; % 定义滑动窗口大小和步长 windowSize = [20 20]; stepSize = [10 10]; % 定义A*算法参数 heuristic = 'euclidean'; diagonalCost = sqrt(2); % 初始化路径和路径花费 path = []; pathCost = inf; % 循环滑动窗口 for i = 1:stepSize(1):(size(map,1)-windowSize(1)) for j = 1:stepSize(2):(size(map,2)-windowSize(2)) % 提取当前窗口内的区域 window = map(i:i+windowSize(1)-1, j:j+windowSize(2)-1); % 判断当前窗口内是否有障碍物 if any(window(:) == 1) % 如果有障碍物,不进行操作 continue; else % 如果没有障碍物,将窗口中心点作为起点 currentPoint = [i+windowSize(1)/2, j+windowSize(2)/2]; % 进行A*算法路径规划 [pathSegment, pathSegmentCost] = AStar(startPoint, endPoint, obstacles, heuristic, diagonalCost, currentPoint); % 判断当前路径段是否更优 if pathSegmentCost < pathCost % 如果更优,则更新路径和路径花费 path = pathSegment; pathCost = pathSegmentCost; end % 在地图上显示当前路径段 hold on; plot(pathSegment(:,2), pathSegment(:,1), 'r', 'LineWidth', 2); hold off; % 等待一段时间,方便观察 pause(0.1); end end end % 显示最优路径 hold on; plot(path(:,2), path(:,1), 'g', 'LineWidth', 2); hold off; ``` 上述代码中,我们首先创建了一个100x100的地图,并在地图上随机生成了三个大小不一的障碍物。接着,我们定义了起点和终点,并使用A*算法进行路径规划。在每个窗口内,我们将窗口中心点作为当前起点,并使用A*算法规划路径。如果当前路径段更优,则更新路径和路径花费,并在地图上显示路径。最后,我们显示最优路径。 在代码中,我们使用了一个名为AStar的函数来实现A*算法路径规划。以下是该函数的示例代码: ```matlab function [path, pathCost] = AStar(startPoint, endPoint, obstacles, heuristic, diagonalCost, currentPoint) % 初始化起点和终点 startNode = struct('pos', startPoint, 'g', 0, 'h', 0, 'f', 0, 'parent', []); endNode = struct('pos', endPoint, 'g', 0, 'h', 0, 'f', 0, 'parent', []); % 初始化开放列表和关闭列表 openList = startNode; closedList = []; % 循环直到找到路径或者开放列表为空 while ~isempty(openList) % 从开放列表中选择f值最小的节点 currentNode = openList(1); for i = 2:length(openList) if openList(i).f < currentNode.f currentNode = openList(i); end end % 如果当前节点是终点,则返回路径 if isequal(currentNode.pos, endNode.pos) path = reconstructPath(currentNode); pathCost = currentNode.g; return; end % 将当前节点从开放列表中移除,并添加到关闭列表中 openList = openList([1:(find(ismember([openList.pos], currentNode.pos))-1) (find(ismember([openList.pos], currentNode.pos))+1):end]); closedList = [closedList currentNode]; % 扩展当前节点的子节点 for i = -1:1 for j = -1:1 if i == 0 && j == 0 continue; end % 计算子节点的位置和花费 childPos = currentNode.pos + [i, j]; if i ~= 0 && j ~= 0 childCost = diagonalCost; else childCost = 1; end % 判断子节点是否在地图范围内 if childPos(1) < 1 || childPos(1) > size(obstacles,1) || childPos(2) < 1 || childPos(2) > size(obstacles,2) continue; end % 判断子节点是否在障碍物上 if obstacles(childPos(1), childPos(2)) == 1 continue; end % 计算子节点的g值、h值和f值 childG = currentNode.g + childCost; childH = heuristicCost(childPos, endNode.pos, heuristic); childF = childG + childH; % 判断子节点是否在关闭列表中,并且是否更优 childNode = struct('pos', childPos, 'g', childG, 'h', childH, 'f', childF, 'parent', currentNode); if any(ismember([closedList.pos], childPos)) && childG >= [closedList(ismember([closedList.pos], childPos)).g] continue; end % 判断子节点是否在开放列表中,并且是否更优 if any(ismember([openList.pos], childPos)) if childG < [openList(ismember([openList.pos], childPos)).g] openList(ismember([openList.pos], childPos)).g = childG; openList(ismember([openList.pos], childPos)).h = childH; openList(ismember([openList.pos], childPos)).f = childF; openList(ismember([openList.pos], childPos)).parent = currentNode; end else openList(end+1) = childNode; end end end end % 如果开放列表为空,则无法找到路径 path = []; pathCost = inf; end % 辅助函数:计算启发式距离 function cost = heuristicCost(currentPos, endPos, heuristic) if strcmp(heuristic, 'euclidean') cost = sqrt(sum((currentPos-endPos).^2)); elseif strcmp(heuristic, 'manhattan') cost = sum(abs(currentPos-endPos)); elseif strcmp(heuristic, 'diagonal') cost = max(abs(currentPos-endPos)); end end % 辅助函数:重构路径 function path = reconstructPath(endNode) path = []; while ~isempty(endNode.parent) path = [endNode.pos; path]; endNode = endNode.parent; end path = [endNode.pos; path]; end ``` 在A*算法中,我们首先初始化起点和终点,并将起点加入开放列表。接着,我们循环直到找到路径或者开放列表为空。在每次循环中,我们从开放列表中选择f值最小的节点,并将其从开放列表中移除,并添加到关闭列表中。然后,我们扩展当前节点的子节点,并计算子节点的g值、h值和f值。如果子节点在开放列表或关闭列表中并且不是更优的,则不添加到开放列表中。最后,如果找到终点,则返回路径和路径花费。 希望这个示例代码能够对你有所帮助。
评论 21
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值