GUI Static Text didnt show anything

3 ビュー (過去 30 日間)
Soveatin Kuntur
Soveatin Kuntur 2021 年 5 月 12 日
回答済み: Walter Roberson 2021 年 5 月 12 日
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);

回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 5 月 12 日
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.

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by