在MATLAB中将多个2维.mat文件转换为单个3维.mat文件

时间:2015-11-05 10:04:53

标签: arrays matlab

我有79个.mat文件,每个文件包含一个名为“CM”的264 * 264数组。我想将它们全部组合成一个264 * 264 * 79矩阵,但我不知道如何。

1 个答案:

答案 0 :(得分:2)

public class MainActivity extends AppCompatActivity {
    EditText usr_nm;
    TextView log_succ;
    Button logs;
    EditText pass_edit;
    int  counter=5;
    String log_msg="login successful";
    Button log_btn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        log_succ=(TextView) findViewById(R.id.log_succ);
        usr_nm=(EditText) findViewById(R.id.usr_nm);
        pass_edit=(EditText)findViewById(R.id.pass_edit);



    }
    public  void  log(View view) {

        if (usr_nm.getText().toString().equals("admin") &&
                pass_edit.getText().toString().equals("admin")) {
            log_succ.setText(log_msg);
            log_succ.setContentDescription("Login successful");
//            log_succ.isFocusable();

//            Toast.makeText(MainActivity.this, "password is correct", Toast.LENGTH_LONG).show();
//            Intent in = new Intent("com.example.samir.login_form.user_page");
//            startActivity(in);


        } else {
            Toast.makeText(MainActivity.this, "password is incorrect", Toast.LENGTH_SHORT).show();
            counter--;
            if (counter == 0)
                logs.setEnabled(false);

        }
    }

files=dir('*.mat') %// load all filenames from the directory ending on .mat for ii = numel(files):-1:1 %// let the loop run backwards load(files(ii).name); A(:,:,ii) = CM; %// assumed they are actually all equivalently called CM end 命令获取dir(当前工作目录)中所有文件的列表。 pwd循环向后运行,以便将存储变量for初始化为其最大大小,从而提高效率。在循环中,加载文件,然后将其存储在A中。最后A将是A数组。