how to use "save" command in matlab as an indexable command

1 回表示 (過去 30 日間)
Ramin
Ramin 2020 年 4 月 26 日
コメント済み: Ramin 2020 年 4 月 26 日
how to use 'save' command in matlab as an indexable command matlab indexing save wavelet There is a matrix of 2550*720 dimension. Each row of this matrix is changed to an image by wavelet transform. The problem is that 'save' command in matlab, store all of 2550 images together in one image.The question is how to indexing 'save' command to store these images separately? Thank you
  2 件のコメント
Sriram Tadavarty
Sriram Tadavarty 2020 年 4 月 26 日
Ramin,
Can you post the code that you tried? So that it makes simple to suggest the modifications.
Ramin
Ramin 2020 年 4 月 26 日
編集済み: Ramin 2020 年 4 月 26 日
if true
% code
endsure. this is my code:
clc;
clear;
close all;
load P300
load nP300
t = 1:100;
waveletname = 'db1';
P300_cwavelet=[];
ext = '.txt';
for i = 1 : size(P300,1)
y = cwt(P300(i,:),t,waveletname);
P300_cwavelet = [P300_cwavelet;y];
save('P300_cwavelet','P300_cwavelet');
end

サインインしてコメントする。

採用された回答

Sriram Tadavarty
Sriram Tadavarty 2020 年 4 月 26 日
Hi Ramin,
You can use a different mat file name to save each wavelet. Since, this was placed in for loop, it is always storing the last one.
Try the modification as below:
clc; clear; close all;
load P300
load nP300
t = 1:100;
waveletname = 'db1';
P300_cwavelet=[];
ext = '.txt';
for i = 1 : size(P300,1)
y = cwt(P300(i,:),t,waveletname);
P300_cwavelet = [P300_cwavelet;y];
save(['P300_cwavelet ' num2str(i)],'P300_cwavelet'); % Name as loop index attached
end
Hope this helps.
Regards,
Sriram
  1 件のコメント
Ramin
Ramin 2020 年 4 月 26 日
thanks a million. yes it worked

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 4 月 26 日
You cannot do that. save() always saves the entire variable named, so you will have to put them into seperate variables. The one exception to that, is using the -struct option: if you have a scalar struct and use the -struct option then instead of it saving the entire struct as one variable, it will create one variable for each field name in the struct.
You should also look at matFile, which is able to read parts of an array from a .mat file.

カテゴリ

Help Center および File ExchangeImages についてさらに検索

製品


リリース

R2013a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by