excel - MATLAB:带有矩阵数据的散点图
问题描述
我正在尝试使用 MATLAB 上的以下代码执行每个大小X
的Y
矩阵的散点图。54x365
数据是从excel中提取的。
clc
clear
A = xlsread('Test_data.xlsx', 'Sheet 1', 'F3:NF56');
B = xlsread('Test_data.xlsx', 'Sheet 2', 'F3:NF56');
scatter (A,B)
尽管它们的大小相似,但 MATLAB 会生成以下语句:
Error using scatter (line 44)
X and Y must be vectors of the same length.
Error in Untitled2 (line 11)
scatter(A,B)
请注意以下事项:
A = [ A, B, C, D, E ;
F, G, H, I, J ]
B = [ a, b, c, d, e ;
f, g, h, i, j ]
绘制变量(A,a)
等(B,b)
以产生散点图。
我需要帮助来执行散点图。谢谢你。
解决方案
将数组重塑为行向量可能允许scatter()
函数绘制数据。Number_Of_Values
在这里,数组被重新整形以在每个数组中具有 1 的维度。
%Generating random test data%
A = rand(54,365);
B = rand(54,365);
%Reshaping to allow plotting%
Number_Of_Values = numel(A);
A = reshape(A,[1 Number_Of_Values]);
B = reshape(B,[1 Number_Of_Values]);
scatter(A,B);
使用 MATLAB R2019b 运行
推荐阅读
- java - toFile().listFiles() 上的 NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE
- google-bigquery - BigQuery 缓存导致的潜在问题
- php - 如何仅在域人员中进行标头身份验证请求?
- batch-file - 使用批处理文件替换文本文件中整数值周围的单引号
- mongodb - 使用 shell 脚本创建多个 monogdb 数据库
- vue.js - Vue 计算属性不响应状态变化
- wordpress - 如何解决 WordPress 站点中的“预加载密钥请求”性能问题?
- javascript - 如何从数组中删除匹配值以外的对象?
- python - 在 python 中使用二分搜索处理分数的问题
- javascript - 从 setTimeout 访问 DOM 元素