[英]Fortran data declaration, MATLAB translation
I have to translate in MATLAB this Fortran statement (variable initialization): 我必须在MATLAB中翻译这个Fortran语句(变量初始化):
data k/350*' '/
where k
was declared like 其中k
被宣布为
character*2 k(31,12)
I have read that *
is equal to comma, that is to say k
will be an array of two elements, 350 and an empty cell? 我已经读过*
等于逗号,也就是说k
将是两个元素的数组,350和一个空单元格?
What should I write in MATLAB? 我应该在MATLAB中写些什么? This k=['350',''];
这个k=['350',''];
? ?
In a data
statement *
is not the same as ,
: ,
is a separator, but *
is a repeat count specifier. 在data
声明中*
是不一样的,
: ,
是一个分隔符,但*
是重复次数符。
The example of the question 问题的例子
character*2 k(31,12)
data k/350*' '/
has the initialization value equal to 700 blanks and k
is a rank-2 array (of shape [31,12]
) of length-2 characters. 初始值等于700个空白, k
是长度为2个字符的等级2阵列(形状[31,12]
)。
Ideally, the size of k
would be identical to the size of the initialization value expression but there is a difference: 744, and 700. Let's just assume that the intention is that each element of the array k
has value ' '
(ie., all blanks). 理想情况下, k
的大小将与初始化值表达式的大小相同但存在差异:744和700.我们假设意图是数组k
每个元素都具有值' '
(即,所有空白)。
As to the best way of doing that in MATLAB, I'm no expert. 至于在MATLAB中这样做的最佳方式,我不是专家。 But if necessary I'll add a way (or someone else can). 但如果有必要,我会添加一种方式(或其他人可以)。 Hopefully the explanation of what the Fortan code is (intended to do/) doing is sufficient. 希望解释Fortan代码(打算做/)做的事情就足够了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.