matlab - 如何为某些点绘制具有不同颜色的网格(MATLAB)
问题描述
问题
我有一个方形网格,尺寸为 NxN,网格点/节点之间的间距恒定。我想绘制这个网格,但有些点很特别,希望它们以不同的颜色绘制。
期待
预期的情节应该是这样的,但有些块必须有不同的颜色!
代码
下面给出了我荒谬而缓慢的解决方案:
N = 80;
x = 1:1:N;
y = 1:1:N;
rx = randi([1 80],1,1000); %represents the x coordinates of the special points
ry = randi([1 80],1,1000); %represents the y coordinates of the special points
[X,Y] = meshgrid(x,y);
Z = zeros(80,80);
figure(1)
surf(X,Y,Z);
%Abandon surf, use scatter instead
figure(2)
for i=1:N
for j=1:N
plot(x(i),y(j),'bo');
hold on
end
end
for i=1:1000
plot(rx(i),ry(i),'ro');
hold on
end
grid on
因为我的眼睛在流血,正确的做法是什么?非常感谢。
解决方案
推荐阅读
- javascript - 关闭按钮旁边的模态标题中的浮动按钮
- python - LIBSVM 精度错误:精度为零
- python - 基于选定用户的 Twitter 情绪分析
- ruby-on-rails - 如何重新加载rails环境?`reload!` 命令是否已弃用?
- reactjs - 使用 React.cloneElement 时如何将道具传递给样式组件
- ios - 在 SwiftUI 中完成动画后隐藏和显示视图
- reactjs - Adsense 不会批准我的 reactjs 应用程序,有什么解决方法吗?
- angular - 数组第一次没有填充
- excel - 从范围中提取数据的 Excel 输入字段
- java - 如何从 jacoco 报告中正确排除和包含类、包和 jar 类、lib(离线仪器)