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
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
HANZU OLIVIU-MIHAI 2022 年 1 月 25 日
The first one should look like this but with mesh
Rik
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
HANZU OLIVIU-MIHAI 2022 年 1 月 25 日
How can I do that ?
Rik
Rik 2022 年 1 月 25 日
doc xlim
doc ylim
doc zlim
Or even just simply with axis.
HANZU OLIVIU-MIHAI
HANZU OLIVIU-MIHAI 2022 年 1 月 25 日
Did you know how can I change the number of faces from the slide var?
Voss
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
HANZU OLIVIU-MIHAI 2022 年 1 月 25 日
I get this error after writing the code
Voss
Voss 2022 年 1 月 25 日
編集済み: Voss 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 ExchangeLabels and Annotations についてさらに検索

タグ

質問済み:

2022 年 1 月 25 日

編集済み:

2022 年 1 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by