My vectors are not the same length
조회 수: 9 (최근 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에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!