Error using plot Vectors must be the same length
이전 댓글 표시
I'm getting the error "Error using plot Vectors must be the same length", however I can't quite figure out where the error is in using plot. I am attaching a photo of the code.

댓글 수: 11
Mathieu NOE
2023년 5월 4일
hello
a photo of a code is not very helpful
better if you can share the code itself and data to test it
have you at least checked the size of the data you are plotting ?
Dyuman Joshi
2023년 5월 4일
To add to Mathieu's comment, you are trying to plot n_for points in x vs (1 + n_for) points in y, which is not possible and thus you get the error.
Michal Kalowski
2023년 5월 4일
Michal Kalowski
2023년 5월 4일
Dyuman Joshi
2023년 5월 4일
"In x or y should I change the length of the vector?"
Depends on what you want to do. What are you trying to plot? What is the expected output?
Michal Kalowski
2023년 5월 4일
Dyuman Joshi
2023년 5월 4일
Is there any reason why you are concatenating x(end) with the data form yfor?
If it is important than you will have to adjust yfor, otherwise you can remove x(end) and plot against the data from yfor.
Michal Kalowski
2023년 5월 4일
Dyuman Joshi
2023년 5월 4일
편집: Dyuman Joshi
2023년 5월 4일
Either try this -
plot(length(x)+(1:n_for), cell2mat(yfor), 'r')
or
plot(length(x)+(1:n_for), [x(end); cell2mat(yfor(1:end-1))], 'r')
Michal Kalowski
2023년 5월 4일
Michal Kalowski
2023년 5월 9일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!