loop variable picking elements of three different vectors separately
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
I am trying to make a loop with loop variable picking elements of three vectors separately. I am trying to keep the result in the same figure with the axis parameters same. I am sharing the code below. How do we generate three plots all in the same figure? Your suggestion will be highly appreciated.
Thanks
Dharma
syms x t
n_weeks = 30;
c1(x) = 1;
vec_1 = reshape((0:n_weeks-1)*7+[1;4],1,[]);%Monday & Thursday
vec_2 = reshape((0:n_weeks-1)*7+[1;3;5],1,[]);%Monday, Wednesday, Friday
vec_3 = zeros(1,60,'uint32');% This vector is simply zero for all days.
for j=[vec_1, vec_2, vec_3] % Here I am trying tell j to pick elements of each vectors separately so that there will be...
% three plots in the same graph with same axis parameter.
c1(x) = c1(x)+15*(x-j);
end
댓글 수: 1
답변 (1개)
Vishesh
2022년 10월 27일
- I am not clear why are you combining "vec_1" , "vec_2" and "vec_3" in "for" loop.
For the given scenario you may try following approach:
- Calculate the data of each of the three plots and store it seperately.
- Suppose data stored in "x1", "x2" and "x3";
- Now you can plot all of these three data in single figure using following approach:
plot(x1,y1);
hold on;
plot(x2,y2);
hold on;
plot(x3,y3);
hold off;
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!