Why does my code open the code for fittype, and then ask me to click continue?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Aron Wiener
il 5 Lug 2023
Risposto: ProblemSolver
il 5 Lug 2023
I am a fairly new Matlab user. Right now, I am trying to create a code to fit a surface with 4 coefficients. Here is my code:
ft=fittype( @(a, b, c, d, x, y) a.*x.^b+c.*x.^2.*y+d.*x.^1.5.*y.^0.5, 'independent', {'x', 'y'},'dependent', 'z' );
fit=fit([polarization,frequency],losses,ft);
Where polarization, frequency, and losses are all 55x1 double arrays. However, when I run the code, it will stop, and display this message in the command window:
314 [varargin{:}] = convertStringsToChars(varargin{:});
K>>
It then takes me to the fittype.m file and leaves me at line 314. The code then will not run anymore until I hit enter on my keyboard and then continue on the top panel. However, the curve it produces doesn't seem logical, but that may be a different problem. Why does this happen and how can I fix it? Any help is greatly appreciated. Thank you.
0 Commenti
Risposta accettata
ProblemSolver
il 5 Lug 2023
This is because you are passing different data type:
ft=fittype( @(a, b, c, d, x, y) a.*x.^b+c.*x.^2.*y+d.*x.^1.5.*y.^0.5, 'independent', {'x', 'y'},'dependent', 'z' );
This line is expecting you to enter character arrays (as in strings) for the independent and dependent arguments, however you are passing cell arrays of string instead. Therefore you have to convert those using a MATLAB function called 'char'. Something like this:
x = char('x');
This should resolve the issue.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Linear and Nonlinear Regression in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!