Convert form string to number
이전 댓글 표시
Hello, I have in app designer 6 TextField that create an ellipsoid and i converted with str2double but the ellispoid looks the same with any numbers.
properties (Access = private)
xc = []; xr = [];
yc = []; yr = [];
zc = []; zr = [];
n = [];
end
% Callbacks that handle component events
methods (Access = private)
% Value changed function: DesenareStergereCheckBox
function DesenareStergereCheckBoxValueChanged(app, event)
app.xc = app.xcEditField.Value;
app.yc = app.ycEditField.Value;
app.zc = app.zcEditField.Value;
app.xr = app.xrEditField.Value;
app.yr = app.yrEditField.Value;
app.zr = app.zrEditField.Value;
[X,Y,Z] = ellipsoid(str2double(app.xc), str2double(app.yc), str2double(app.zc), str2double(app.xr), str2double(app.yr), str2double(app.zr));
axis equal
if app.DesenareStergereCheckBox.Value
set(mesh(app.UIAxes,X,Y,Z),'visible','on')
else
set(mesh(app.UIAxes,X,Y,Z),'visible','off')
end
end

댓글 수: 9
Rik
2022년 1월 25일
They don't look the same to me. Look at the axis ranges. Also, the bottom one looks rounder to me, although that could simply be the data aspect.
You probably want to use the daspect function:
daspect([1 1 1])
HANZU OLIVIU-MIHAI
2022년 1월 25일
Rik
2022년 1월 25일
All three axis ranges are different between the surf you showed and the screenshot of AppDesigner. How am I supposed to tell the difference?
If you want static ranges for your axis you will have to set them explicitly.
HANZU OLIVIU-MIHAI
2022년 1월 25일
Rik
2022년 1월 25일
doc xlim
doc ylim
doc zlim
Or even just simply with axis.
HANZU OLIVIU-MIHAI
2022년 1월 25일
Voss
2022년 1월 25일
app.xc = app.xcEditField.Value;
app.yc = app.ycEditField.Value;
app.zc = app.zcEditField.Value;
app.xr = app.xrEditField.Value;
app.yr = app.yrEditField.Value;
app.zr = app.zrEditField.Value;
app.n = app.nSlider.Value; % <-- use whatever your slider is called instead of "nSlider" here
[X,Y,Z] = ellipsoid( ...
str2double(app.xc), ...
str2double(app.yc), ...
str2double(app.zc), ...
str2double(app.xr), ...
str2double(app.yr), ...
str2double(app.zr), ...
app.n);
HANZU OLIVIU-MIHAI
2022년 1월 25일
I guess you have to convert n to a number first (apparently contradicting the documentation for uislider(), which states that Value is numeric - who knows, maybe that's not a uislider() you have there at all, there is no way for me to know):
app.xc = app.xcEditField.Value;
app.yc = app.ycEditField.Value;
app.zc = app.zcEditField.Value;
app.xr = app.xrEditField.Value;
app.yr = app.yrEditField.Value;
app.zr = app.zrEditField.Value;
app.n = app.nSlider.Value; % <-- use whatever your slider is called instead of "nSlider" here
[X,Y,Z] = ellipsoid( ...
str2double(app.xc), ...
str2double(app.yc), ...
str2double(app.zc), ...
str2double(app.xr), ...
str2double(app.yr), ...
str2double(app.zr), ...
str2double(app.n));
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Labels and Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

