简体   繁体   English

无法在Octave中绘制简单图形

[英]Failed to plot simple graph in Octave

I want to draw a line on a graph to find the intersection point with another line. 我想在图形上画一条线以找到与另一条线的交点。 However, there's no response after I executed the script below. 但是,执行以下脚本后没有任何响应。 May I know what is the problem and how can I solve it? 请问问题出在哪里,如何解决?

x=1:2^20;
y2=2^24;
plot(x,y2);

Thanks! 谢谢!

What you want is to plot a line on 2^24. 您要在2 ^ 24上画一条线。 However, there are too many points for you computer probably, and you run out of memory 但是,您的计算机可能有太多的问题,并且内存不足

I am guessing that you'll need to plot your other inequality as well. 我猜您也需要绘制其他不平等情况。

Something like 就像是

x=1:100:2^20;                    
% As Zoran and others suggested, You may not want all the points!
% It is too much memory
y2=2^24*ones(size(x)); % This ones is optional, but its good to know what you are doing (personal opinion)
plot(x,y2);
hold on
y1=(x+1).*log(x);
plot(x,y1);

在此处输入图片说明

However, you are still not there! 但是,您仍然不在那里!

Another solution, which does not rely on plotting: 另一个不依赖于绘图的解决方案:

>> f = @(x) (x+1)*log(x)-2^24;
>> soln = fzero(f,1e6)
soln =   1.1987e+006
>> f(soln)
ans =   3.7253e-009

So your intersection point is at 1.1987e6 . 所以您的交点在1.1987e6

Apparently,you have too many points for x, 2^20 Have to wait program to calculate, or plot,for example, every 100th point 显然,x的点太多,2 ^ 20必须等待程序来计算或绘图,例如,每100个点

This solution works for Matlab 该解决方案适用于Matlab

x=1:100:2^20;
y2=2^2;
plot(x,y2,'o');

There is one more and maybe a bit smarter way: if you want to solve ((k+1)(ln k)<2^24) as you've commented above, use fsolve function to get just solution of an equation(!). 还有另一种,也许是一种更聪明的方法:如果您如上所述想求解((k + 1)(ln k)<2 ^ 24),请使用fsolve函数获取方程的正解(! )。 Then use that solution to specify the area of your interest, so you won't have to plot the domain of 2^20. 然后使用该解决方案来指定您感兴趣的区域,这样您就不必绘制2 ^ 20的域。 (All functions are continuous so you don't have to worry about any wild singularities. Just examine the neigborhood of ks for which (k+1)(ln k)-2^24=0.) (所有函数都是连续的,因此您不必担心任何野奇性。只需检查(k + 1)(ln k)-2 ^ 24 = 0的ks的邻域。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM