MATLAB: How to tell matlab in a matrix that if the program does not assign value to an element do not fill it with 0

matrix

I'm doing a program in matlab with the gui, which is gauss jordan at the beginning my program is asking for the elements of the matrix but my program can store up to 5×6 then when you enter a 2×3 matrix the others fill it with 0 which I get an error when it comes to giving me results How can I tell him not to fill it with 0?

Best Answer

thanks for answering but I solved my problem, when the user presses 2x2 what pushbutton does is declare as symbolic variable au, assign the value of u and save it with setappdata and so with the other buttons, u = 2, u = 3 etc . When you press the solve button I declare the symbolic variable u and I get the value of u according to the point that you pressed with getappdata. next I show you the code
function 2x2_Callback(hObject, eventdata, handles)
syms u
u=1
setappdata (0, 'evalue', u);
function solvethesystem_Callback(hObject, eventdata, handles)
syms u
u = getappdata (0, 'evalue');
switch u
case 1
m=[str2double(get(handles.edit3,'string')) str2double(get(handles.edit4,'string')) (str2double(get(handles.edit9,'string'))); str2double(get(handles.edit10,'string')) str2double(get(handles.edit11,'string')) str2double(get(handles.edit15,'string'))]
case 2
m=[str2double(get(handles.edit3,'string')) str2double(get(handles.edit4,'string')) str2double(get(handles.edit6,'string')) (str2double(get(handles.edit9,'string'))); str2double(get(handles.edit10,'string')) str2double(get(handles.edit11,'string')) str2double(get(handles.edit12,'string')) (str2double(get(handles.edit15,'string'))); str2double(get(handles.edit16,'string')) str2double(get(handles.edit17,'string')) str2double(get(handles.edit18,'string')) str2double(get(handles.edit21,'string')) ]
case 3
m=[str2double(get(handles.edit3,'string')) str2double(get(handles.edit4,'string')) str2double(get(handles.edit6,'string')) str2double(get(handles.edit7,'string')) (str2double(get(handles.edit9,'string'))); str2double(get(handles.edit10,'string')) str2double(get(handles.edit11,'string')) str2double(get(handles.edit12,'string')) str2double(get(handles.edit13,'string')) (str2double(get(handles.edit15,'string'))); str2double(get(handles.edit16,'string')) str2double(get(handles.edit17,'string')) str2double(get(handles.edit18,'string')) str2double(get(handles.edit19,'string')) (str2double(get(handles.edit21,'string'))); str2double(get(handles.edit22,'string')) str2double(get(handles.edit23,'string')) str2double(get(handles.edit24,'string')) str2double(get(handles.edit25,'string')) str2double(get(handles.edit27,'string')) ]
case 4
m=[str2double(get(handles.edit3,'string')) str2double(get(handles.edit4,'string')) str2double(get(handles.edit6,'string')) str2double(get(handles.edit7,'string')) str2double(get(handles.edit8,'string')) (str2double(get(handles.edit9,'string'))); str2double(get(handles.edit10,'string')) str2double(get(handles.edit11,'string')) str2double(get(handles.edit12,'string')) str2double(get(handles.edit13,'string')) str2double(get(handles.edit14,'string')) (str2double(get(handles.edit15,'string'))); str2double(get(handles.edit16,'string')) str2double(get(handles.edit17,'string')) str2double(get(handles.edit18,'string')) str2double(get(handles.edit19,'string')) str2double(get(handles.edit20,'string')) (str2double(get(handles.edit21,'string'))); str2double(get(handles.edit22,'string')) str2double(get(handles.edit23,'string')) str2double(get(handles.edit24,'string')) str2double(get(handles.edit25,'string')) str2double(get(handles.edit26,'string')) (str2double(get(handles.edit27,'string'))); str2double(get(handles.edit28,'string')) str2double(get(handles.edit29,'string')) str2double(get(handles.edit30,'string')) str2double(get(handles.edit31,'string')) str2double(get(handles.edit32,'string')) str2double(get(handles.edit33,'string')) ]
otherwise
x=0
end