gpt4 book ai didi

function - SciLab 绘图

转载 作者:太空宇宙 更新时间:2023-11-03 20:22:04 25 4
gpt4 key购买 nike

您将如何在 SciLab 或 MatLab 中绘制这些图?我对这些不熟悉,不知道该软件是如何工作的。请帮忙。

$Plot following functions with different colors in Scilab or MatLab
– f2(x) = logn
– f3(x) = n
– f4(x) = nlogn
– f5(x) = n2
– f6(x) = nj (j > 2)
– f7(x) = cn (c > 1)
– f8(x) = n!

where x = linspace(1, 50, 50).

最佳答案

好吧,其中很多都是内置函数。例如

>> x = linspace(1,50,50);
>> plot(x,log(x))
>> plot(x,x)
>> plot(x,x.*log(x))
>> plot(x,x.^2)

我不知道nj (j > 2)cn (c > 1) 是什么意思。

对于最后一个,您应该查看函数 factorial

从上下文中不清楚您是应该将它们绘制在不同的图表上还是全部绘制在同一个图表上。如果都在同一张图上,那么你可以使用

>> hold on;

卡住当前轴 - 这意味着任何新线都将绘制在旧线之上,而不是绘制在一组新的轴上。

在 Matlab 中(可能在 Scilab 中),您可以为 plot 函数提供一个“line spec”参数,它告诉它用什么颜色和样式来画线。例如,

>> figure
>> hold on
>> plot(x,log(x),'b')
>> plot(x,x/10,'r')
>> plot(x,x.^2/1000,'g')

告诉 Matlab 绘制函数 f(x)=log(x) 蓝色,f(x)=x/10 红色和 f (x)=x^2/1000 为绿色,结果为该图:

enter image description here

关于function - SciLab 绘图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12685125/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com