How can I plot a plot with two parameters?
显示 更早的评论
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!
采纳的回答
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
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?
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.
" 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)
