Hey guys would anyone know what is wrong with my code? I have two single tables set up i.e. (71 rows x 1 column) called S and R (tag names). And i want to convert them into simple column matrix i.e. arrays. However from point of %ok i get stuck. Would anyone know what is wrong? I think it is to do with 'table array' being different to 'column matrix' or fsolve not executing for some reason
d = str2double(get(handles.dp,'string')); %ok
o = str2double(get(handles.oi,'string'));%ok
w = str2double(get(handles.w,'string'));%ok
m = str2double(get(handles.m,'string'));%ok
d=d*10^-6;%ok
b0= [1.98; 2.15*d];%ok
X=get(handles.S,'Data');%OK
Y=get(handles.R,'Data');%OK
options=optimset('Display','iter'); %OK
myfun = @(b) [((1-w.*((((b(2).*(d).^(2-b(1)))./(o.*Y.*X)).^(1/(4- b(1))))./(d)).^(3-b(1)))./((1)-(w.*((((b(2).* (d).^(2-b(1)))./(o.*Y.*X)).^(1/(4-b(1))))./(d)).^(3-b(1)))./m).^2)-Y] %OK
opts = optimoptions('fsolve', 'TolFun', 1E-8, 'TolX', 1E-8); %OK
[b,fval,exitflag] = fsolve(myfun,b0) %%%??????????? i think this might be causing problem?

 Réponse acceptée

Image Analyst
Image Analyst le 3 Juin 2015

0 votes

What is the data type of x? If your uitable is all numbers, x is probably a double array. If not, then x might be a cell array or a table. What does this say
whos x
To use table2array(), x must be of class "table" and not double or cell.

7 commentaires

sarah
sarah le 3 Juin 2015
Modifié(e) : sarah le 3 Juin 2015
it's double right now i.e. my data in the table in my GUI. How do i change it?
All my data is double and I want to keep that but convert double values in my table to normal array.
This is what its telling me "Undefined function 'times' for input arguments of type 'cell"
I was just getting the data i.e. x=get(handles.S,'Data') and putting into equation however it doesnt let me do that.
Image Analyst
Image Analyst le 3 Juin 2015
There is nothing to do. x is double already, so there is no need to call X = table2array(x) at all . x is already an array so you're done .
sarah
sarah le 3 Juin 2015
Modifié(e) : sarah le 3 Juin 2015
are you sure? Because when i use fsolve to solve my equation it doesn't execute it. This might be stupid but there different
From GUI table
Y =
[1.1812] ''
[1.1863] ''
[1.1968] ''
[1.2026] ''
[1.2204] ''
Normal column matrix
Y =
1.1812
1.1863
Image Analyst
Image Analyst le 3 Juin 2015
Read my answer again and then show us what whos says. You didn't run whos on x and tell us what it said like I requested. Then, do the same thing for Y if you've uncommented it.
sarah
sarah le 3 Juin 2015
Modifié(e) : sarah le 3 Juin 2015
Name Size Bytes Class Attributes
x 71x1 568 double
Name Size Bytes Class Attributes
X 71x1 568 double
Your right sorry about that. I guess it is some other mistake I'm making? It's so strange though. I use the push button called plot to get the data. Maybe i have to initialize/call back the table data elsewhere I'm assuming.Thanks though!
Image Analyst
Image Analyst le 3 Juin 2015
I'm still not sure what you want to do. Somehow you put x into uitable S, and Y into uitable R, and you simply want to extract them back out of those uitables. So what is the problem? You're getting x out and it's a double array. What is wrong with that?
sarah
sarah le 4 Juin 2015
Yes, but when i use fsolve to solve it, it gives me an error saying "Undefined function 'times' for input arguments of type 'cell'" when i did run my program without GUI it perfectly solved for it where x and y were column matrices or arrays. However fsolve doesn't seem to do solve it anymore now. I tried debugging it and this is where i get stuck.
Thanks.

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by