小编Mik*_*ith的帖子

连接单元格数组

我希望将两个单元阵列连接在一起.我有两个不同大小的矩阵,根据我的理解,将它们连接在一起的唯一可能方法是使用单元格数组.这是我的代码

M = magic(3);
B = {magic(3) 'sip' magic(4) magic(3) }

C = {B; ...
        B; ...
        B; ...
        B}


c1 = C{1}{1,1};
c2 = C{1}{1,3};
c{1} = c1; % after extracting matrix from cell array put it it
c{2} = c2; % into another cell array to attempt to concatenate
conca = [c{1};c{2}]; %returns error.
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

??? Error using ==> vertcat
CAT arguments dimensions are not
consistent.

Error in ==> importdata at 26
conca = [c{1};c{2}]; %returns error.
Run Code Online (Sandbox Code Playgroud)

arrays matlab cell

4
推荐指数
1
解决办法
2万
查看次数

使用main方法在Java中编写单元测试

我班上有几种方法

public class StringChecking
{
public static void main(String[] args);
public void stringChecker(String text, int number); //takes a string and prints that out. 
}
Run Code Online (Sandbox Code Playgroud)

我想编写单元测试来测试' stringChecker()'方法.我想知道我会怎么做.当我StringChecking在JUnit Testing类中创建一个类型的对象时,我似乎无法stringChecker()从该实例访问方法.

StringChecker方法根据参数打印出传入文本的特定数量的单词.我希望检查打印出的前10个单词是否与预期结果相同.

JUnit测试类

String expected = "My name is";
asserEquals(expected, actual);
Run Code Online (Sandbox Code Playgroud)

我猜我会让我的stringChecker方法返回一些东西,以便进行检查.但我不明白为什么我无法从测试类访问该方法.

java junit unit-testing

0
推荐指数
1
解决办法
1万
查看次数

标签 统计

arrays ×1

cell ×1

java ×1

junit ×1

matlab ×1

unit-testing ×1