How can I plot a plot with two parameters?
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Hi,
I want to plot a "ngs(n1+n2+n3+2,:)" that is a "224*67501" matrix, versus longitudinal position(millimeter) "X" which is a "224*1" matrix, At desired time between 0 and 3 nanoseconds. Also "t" is a matrix with 1*67501 and dt=4.4e-14(step time). I try it but I encounter two pronlems. Firstly, "vectors must be the same lenghs" when I want to plot:
plot(X,ngs(n1+n2+n3+2,:))
secondly, I do not know how to draw it at a specific time between 0 and 3 nanoseconds.
Thanks in advance for your guidance!
채택된 답변
dpb
2021년 8월 26일
It would be far easier if you would attach a short(ish) section of your data files themselves instead of us having to try to interpret..what are the ni variables above, for example?
But, the answer to the last question is simply
>> dt=4E-14;
>> N=3E-9/dt
N =
75000
>>
so it takes 75,000 elements at that sample rate to amount to 3 nsec...
댓글 수: 6
Thank you,
I wanted to upload the program but it will not be useful because it takes more than half a day to simulate. I also wanted to upload Workspace, but I was limited. I entered the basic parameters in the code, part of code and attached the photo file from Workspace and desired figure. I still have not found the answer to my question, how is it possible to draw "ngs" in terms of "x" at a given time?
Thank you very much for your help.
n1=100;
n2=22;
n3=100;
tmax=3*10^-9;
dx=zeros(n1+n2+n3+1,1);
for n=1:n1
dx(n,1)=0.5*(l-lsa)/(n1+0.5);
end
for n=n1+2:n1+n2+1
dx(n,1)=lsa/(n2+0.5);
end
for n=n1+n2+2:n1+n2+n3+1
dx(n,1)=0.5*(l-lsa)/(n3+0.5);
end
x(1,1)=0;
for n=1:n1+n2+n3+1
x(n+1,1)=x(n,1)+dx(n,1);
end
dx(n1+1,1)=(dx(n1,1)+dx(n1+2,1))/2;
dx(n1+n2+1,1)=(dx(n1+n2,1)+dx(n1+n2+2,1))/2;
dt=min(dx(n1+n2+2,1),min(dx(1,1),dx(n1+2,1)))/(1.25*vg);
nt=floor(tmax/dt)+1
ngs=zeros(n1+n2+n3+2,nt);
t=0:dt:tmax
n1=100;
n2=22;
n3=100;
tmax=3*10^-9;
dx=zeros(n1+n2+n3+1,1);
dx(1:n1,1)=0.5*(l-lsa)/(n1+0.5);
dx(n1+2:n1+n2+1,1)=lsa/(n2+0.5);
dx(n1+n2+2:n1+n2+n3+1,1)=0.5*(l-lsa)/(n3+0.5);
x=[0;cumsum(dx)];
dx(n1+1)=(dx(n1)+dx(n1+2))/2;
dx(n1+n2+1,1)=(dx(n1+n2,1)+dx(n1+n2+2,1))/2;
dt=min(dx(n1+n2+2,1),min(dx(1,1),dx(n1+2,1)))/(1.25*vg);
nt=floor(tmax/dt)+1
ngs=zeros(n1+n2+n3+2,nt);
t=0:dt:tmax
mohammad heydari
2021년 8월 29일
편집: mohammad heydari
2021년 8월 29일
Thanks for the information, but I've been having this problem for a few days now. Let me ask very simply.I have a matrix N whose dimensions are 3*15. And I want to plot it in terms of the matrix P, which is a 7*1 matrix, and for just one number of the t-matrix, which is 1*15. What should this custom look like?
N=[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15;16 17 18 19 20 21 22 23 24 25 26 27 28 29 30; 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45]
p=[60 70 80 90 100 110 120]'
t=[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 ]
Now, how can i plot it?
dpb
2021년 8월 29일
I still can't follow what you think you want plotted, sorry...what relationship does p have to anything in N and t and what do you expect a plot of just one point out of t to be other than a single point?
Furthermore, the size of p is not commensurate with any of the dimensions of either t or N so what's going to match up with what?
If you can visualize what you think this plot would be, attach a sketch showing how you would draw it by hand, labelling where the various pieces of the above arrays go to produce the figure.
Please ignore the previous message and return to the previous two messages. This piece, which I have given in the figure below, has been completely analyzed. I do not want to bother you with physical concepts. I came up with the correct results given the very complex equations solved. Any parameter that I draw in terms of t, which is time, is the correct result. Now I want to draw each parameter in terms of x, which is the position of a piece, and at a given time t = t0. In the figure below, I have explained these concepts quite simply.

Unfortunately I could not upload workspacet here due to the large size of the workspace, otherwise we might have been able to talk about it easily. Anyway, I have listed them in the attached file above. The relationship between pout, t, x is completely solved without any problems. And the output obtained with the following command is completely correct.
plot(t,pout);
Now drawing the same pout in terms of x and at time t = t0 has caused me problems due to the inequality of the dimensions of pout and x as the first problem and determining a specific time point as the second problem. The desired shape is shown in the attached file as output obtained in the past. I have fully shown the basic values and parameters in the previous two messages. If you still have questions, I will try to answer quickly. Thank you very much.
dpb
2021년 8월 29일
" I could not upload workspacet here due to the large size of the workspace, otherwise we might have been able to talk about it easily. "
Indeed. Surely you can create a subset of the dataset that is sufficient to illustrate the difficulties but that somebody here can actually touch.
Without that, it's going to take somebody a lot more able to figure out what you're asking for than I to be able to help, I'm afraid.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Annotations에 대해 자세히 알아보기
태그
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
