green
green

Reputation: 713

How to prompt input dialog for entering matrix elements in matlab?

I would like to ask is there any way to let the user to the enter matrix elements (eg. a 3x3 matrix) in a input dialog that has a total 9 boxes in a square manner in matlab. I know matlab got a inputdlg function but the input box will only be in a vertical manner. So I would like to know is there any other option other than using GUI. My concept is like asking the user the matrix size and then I will prompt the corresponding number of boxes for the matrix elements.

Upvotes: 0

Views: 3518

Answers (1)

Mark
Mark

Reputation: 11

This is how I have done it (for solving simultaneus equations), however my problem now is using the data in the matrix I dont think this actually creates a matrix because it wont find the det ` clear clc

prompt={'x:','y:','z:'}
dlg_title='MATRIX A'
num_lines=[1 50]
def={'3','4','8'}
A=inputdlg(prompt,dlg_title,num_lines,def)

dlg_title='MATRIX B'
def={'4','3','-3'}
B=inputdlg(prompt,dlg_title,num_lines,def)

dlg_title='MATRIX C'
def={'5','-4','-2'}
C=inputdlg(prompt,dlg_title,num_lines,def)

D=[A,B,C]'`

Upvotes: 1

Related Questions