很难弄明白这件事。这是我第一次做Scilab作业,所以我还是个新手。
表1将把°F转换为K
我附上了一张到目前为止的截图(这是我在网上发现的东西的一部分),但我被困住了。对于输入和行空间(第1和第2部分),我有正确的想法吗?
所有的帮助都是非常感谢的!
发布于 2018-03-03 17:31:57
我不确定(200/Increment1)+1公式是如何使用的,但这就是我理解这个问题的方式,它给出了所需的输出
clear
clc
Increment1=input("Enter number of elements:")
F=linspace(0,200,200/Increment1+1)
for n=1:(200/Increment1)+1
k=(5/9)*(F(n)+459.67)
K(n)=k
end
disp(" F K")
F=F'
A=cat(2,F,K)
disp(A)产出-
Enter number of elements:100
F K
0. 255.37222
100. 310.92778
200. 366.48333发布于 2018-03-06 09:48:21
在scilab中,有两种定义向量的方法:使用步骤(如x=start:step:end中的步骤)或元素总数(如x=linspace(start,end,number) )
因此,如果您希望Increment1元素如建议的那样,您将不得不编写F=linspace(0,200,Increment1)。
实际上,F的两个元素之间的步骤是(end-start)/(number-1),所以您也可以编写F=0:200/(Increment1-1):200。你原来的问题可能有错误,因为我对‘200/增量1+1’部分的数学不理解
正如@user5694329所言,您不应该考虑使用for循环,而应该更多地使用线性代数,如K=(5/9)*(F+459.67) wich转换为:取向量F,将每个元素相加459.67,然后乘以5/9。
还要注意,x=x' (如Rohan所建议的)计算矩阵/向量的转置共轭。对于真正的价值,这并不重要,但你可能会有一些麻烦,在未来,如果你工作的复数。改用x=x.'或x=transpose(x)'。最后,如果您需要一个特定的形状,最好使用矩阵函数:x = matrix(x,-1,1)转换为‘取x,并使它成为1列,并按需要增加行’(显然,x = matrix(x,1,-1)是行版本)。有关更多详细信息,请阅读帮助help matrix。
完整的答案是(这对我来说是有意义的)
clear;
clc;
// 1.Request the user to input the number of elements you want in a vector.
// Call this variable “Increment1”.
Increment1=input("Enter number of elements:");
// Use the linspace function to create a vector from 0°F to 200°F. Name this variable “F”.
F=linspace(0,200,Increment1) // or F=0:200/(Increment1-1):200;
// NOT UNDERSTOOD : and uses the number of elements input by the user in the following formula (200/”increment1”)+1.
F=matrix(F,1,-1); // BONUS : we assure that F is a row
// Use the formula (5/9)*(F +459.67) to create a vector of K values. Name this variable “K”.
K=(5/9)*(F+459.67); // K is also a row since F is
// 4. Concatenate F and K into a 2 row matrix (such that F values are directly on top of K values). Name this variable “A”
A = [F;K] // or cat(1,F,K) : Takes F, change row (;), add K
// Display A
disp(A)https://stackoverflow.com/questions/49078501
复制相似问题