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 Commenti

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])
The first one should look like this but with mesh
Rik
Rik il 25 Gen 2022
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.
How can I do that ?
doc xlim
doc ylim
doc zlim
Or even just simply with axis.
Did you know how can I change the number of faces from the slide var?
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);
I get this error after writing the code
Voss
Voss il 25 Gen 2022
Modificato: Voss il 25 Gen 2022
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));

Accedi per commentare.

Risposte (0)

Categorie

Modificato:

il 25 Gen 2022

Community Treasure Hunt

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

Start Hunting!

Translated by