GUI Static Text didnt show anything

3 Ansichten (letzte 30 Tage)
Soveatin Kuntur
Soveatin Kuntur am 12 Mai 2021
Beantwortet: Walter Roberson am 12 Mai 2021
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);

Antworten (1)

Walter Roberson
Walter Roberson am 12 Mai 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.

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by