How to assigned to a variable vector of the cell?

1 回表示 (過去 30 日間)
Veronika
Veronika 2015 年 3 月 17 日
コメント済み: Veronika 2015 年 3 月 18 日
Dear all,
I have variable xx and cell (velky). I want to choose one vector velky {2,a} (for example velky{2,1})of this cell and assigned to a variable xx. I try to do this, but withnout succes.
This is my code:
load ('testovaci_modely_velke_skvrny')
load ('net')
prompt = {'Napište číslo testovacího modelu:','z'};
dlg_title = 'Vytvoření vlastního testovacího modelu';
num_lines = 1;
x = inputdlg('Napište číslo testovacího modelu:','Vytvoření vlastního testovacího modelu', [1 100]);
a = x{1,1};
disp('Zadali jste správné číslo.')
xx = velky{2,a};
% Y = sim(net,P);
imdl= mk_common_model('a2c0',16);
img_1 = mk_image(imdl);
img_input = img_1;
img_input.elem_data = xx;
figure
show_fem(img_input);
title('Testovací model')
Does anyone have any idea? I work with EIDORS, but in this case it is about vector and cell. Thank you for your answers.
I attach my matfile,testovaci_modely_velke_skvrny and net.

採用された回答

Adam
Adam 2015 年 3 月 17 日
編集済み: Adam 2015 年 3 月 17 日
Please try to include information on any errors with questions like this. Just saying "without success" doesn't really make it easy for us to help quickly.
Looking at your code and running what seems relevant I think the problem is that
a = x{1,1};
is giving you a string as answer because it is taken from an input dialog. You need to convert the string to a number.
Try replacing that with:
a = str2double( x{1,1} );
then your syntax
xx = velky{2,a};
which is correct should work fine.
  1 件のコメント
Veronika
Veronika 2015 年 3 月 18 日
Thank you, this is exactly what I wanted.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by