My vectors are not the same length
8 ビュー (過去 30 日間)
古いコメントを表示
So, I'm working on a code for class and they're asking me to plot two variables that aren't the same length. My time vector is t=0:0.005:500 which is has a length of 1x100 while my other variables are 1x500. What should I do?
this is my code:
clear;
clc;
L=load("ver.mat");
t=0:0.005:500;
Ensembl_avg=mean(L.ver);
plot(t,Ensembl_avg);
hold on;
plot(t,L.actual_ver);
I've also provided the "ver.mat" file just in case.
2 件のコメント
dpb
2023 年 9 月 14 日
load ver
whos
So, what is ver versus actual_ver?
If this is a homework assignment, there must have been instructions as to what was expected -- think we would have to see this assignment to have any klew about it...
Walter Roberson
2023 年 9 月 14 日
t=0:0.005:500;
whos t
Not length 100.
T = 0 : 5 : 500;
whos T
That would be a lot closer to 100... but notice that it is length 101. 0 is divisible by 5; 5 is divisible by 5, 10 is divisible by 5... up to 500 exactly is divisible by 5. There (0:100)*5 is 101 entries not 100 -- you have to count the endpoints.
回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Creating, Deleting, and Querying Graphics Objects についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!