GUI Static Text didnt show anything
1 view (last 30 days)
Show older comments
Hello!
so in the button function I have made code, but unfortunately T static field didnt show anything. I dont why because its not showing any error
function inputmatrices_Callback(hObject, eventdata, handles)
N=str2num(get(handles.n, 'string'));
M=str2num(get(handles.n, 'string'));
x=str2num(get(handles.inputmatrices,'string'));
x(x==0)=-1;
I = eye(N,N);
T = (1/N)*(x*transpose(x)-M*I);
set(handles.T, 'string', T);
0 Comments
Answers (1)
Walter Roberson
on 12 May 2021
We cannot tell for sure what size x is. If inputmatrices is a multi-line edit field in which there was one entry per line, then that would be received as a column vector cell array, and the str2num() into x would be a column vector. (1 x L) * (1 x L).' would be 1 x L * L x 1 which would give 1 x 1, so the left part of the subtraction in T might be 1 x 1. But the right part M*I is going to be a matrix, so we have to assume that T will be an N x N numeric matrix result.
But an N x N numeric matrix result is not a string, and the way it gets converted into a string for display is probably not going to be to your liking. You should do explicit conversion to character or string array or cell array of character vectors in the format you want.
Note by the way that
N=str2num(get(handles.n, 'string'));
M=str2num(get(handles.n, 'string'));
are both fetching from the same handle.
0 Comments
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!