Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Selecting options for saving array

조회 수: 1 (최근 30일)
Marc Hummel
Marc Hummel 2016년 7월 11일
마감: MATLAB Answer Bot 2021년 8월 20일
I want to save a 375x5 array as .txt file. Everything is fine so far until I make a selection via my GUI and some radiobuttons which colums to save. I wrote a script but noticed later on, that it's not possible to select only the last 2 colums because in this case the last colums move forward so they doesn't exist anymore when the code comes to their selection.
Any suggestions how I can change my if- or for-cases to change the problem? Thank you
My code:
calc_diameter = alldia;
if status_diameter(1,1) == 0;
calc_diameter(:,1) = [];
elseif status_diameter(1,1) == 1
end
if status_diameter(2,1) == 0;
calc_diameter(:,2) = [];
elseif status_diameter(2,1) == 1
end
if status_diameter(3,1) == 0;
calc_diameter(:,3) = [];
elseif status_diameter(3,1) == 1
end
if status_diameter(4,1) == 0;
calc_diameter(:,4) = [];
elseif status_diameter(4,1) == 1
end
FinalDia = mean(calc_diameter,2);
StDevDia = std(calc_diameter,1,2);
dlmwrite(SaveName,[xscale calc_diameter],'delimiter','\t');
dlmwrite(SaveName,[xscale FinalDia StDevDia],'delimiter','\t');

답변 (1개)

Friedrich
Friedrich 2016년 7월 11일
Hi,
how about cutting out the data you want to save? You have 5 radio buttons and you can figure out which one is checked. So you can built up an array like this [0 0 0 1 1] where 1 stands for radio button is checked. Once you have that array you can easily do:
selection = logical([0 0 0 1 1]);
alldia = rand(375,5 );
calc_diameter = data(:,selection);

Community Treasure Hunt

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

Start Hunting!

Translated by