Undefined operator '*' for input arguments of type 'matlab.gr​aphics.pri​mitive.Lin​e'.

2 次查看(过去 30 天)
Hello, I am working on Python scripting to make changes over the proposed DoE in Matlab in order to make changes in the model and obtain the results.
When I am passing commands to make changes in the cell structure, I get the error mentioned above. I have tried looking further but I think it has to do with some mathematical oepration on a graphical database which aren't comptabile to work together. But I can't find any other way to make changes in the diemension of my cell.
The problem is when I am trying to define the printf statement whererin I want to write the new data to my text file(pyhton model database script) and then change my mdoel in the abaqus (in background).
Any help is much appreciated. I have described the exact lcoation of error in the text below:::
Problem is mainly in this section and line highlighted in the text below towards the end where I am assigning the value " 0.5 * b(1) "
replaceLine=144;
fid=fopen('BASE_MODEL_MDB.py','r+');
for k=1:(replaceLine-1)
fgetl(fid);
end
fseek(fid,0,'cof');
fprintf(fid,' ''Model-1'', RectangularProfile(a=1.0, b=%5.4f, name=''Profile-2''), ', 0.5*b(1)); %HERE
fclose(fid);
  3 个评论
Nicholas Ayres
Nicholas Ayres 2020-1-7
Could you please clarify what the variable
b
is. Maybe insert the code where it is defined into your question (and respond to me saying you have done so, so that I get the notification).
If I am not mistaken, it appears that b is taken from a graphics handle and you are just incorrectly indexing it to find the data point you are requiring.
Knowing what b is would help me more directly answer your question.
:)
anant mehrotra
anant mehrotra 2020-1-7
Thank you for your prompt response.
'b' is the section dimension defined in Abaqus. I have modeled using rectangular section and I had to define a and b for the section width and length. Now I am trying to change that. In python script at line I have mentioned, there is this profile dimensions a and b and I want r edit b :)
b is 50x1 and contains value ranging from 0.0015-0.007 [m].

请先登录,再进行评论。

采纳的回答

anant mehrotra
anant mehrotra 2020-1-7
编辑:anant mehrotra 2020-1-7
Nicholas Ayres sure I can help you with that. I am going to attach two files which will help you in understanding what b is. The problem is, earlier I wasn't using variable b and I was simply calling it cell_section and assigning values to it as per my DoE (generateDoE.m). And I was using the same in "printf" statement to modify my model in ABAQUS. Everytime I would run the main code, it gave me an error that cell_section is not defined or unknown variabel/function.
So what I did next is to call the variables I am changing with the same name the ABAQUS uses, maybe that could bring this error of graphical and assigning this mathematical value. But anyway, I am attaching the matlab code here.
"python_assembly.m" is called inside "Main.m" which is called inside "DoE.m".
I hope this helps and thank you for your prompt response.
  8 个评论
Steven Lord
Steven Lord 2020-1-23
Set an error breakpoint. Run your code. When you reach the line where the error gets thrown, look at the class of the variable b. I'm pretty sure it will not be a numeric vector but will be a graphics object created by the plot or line functions.
If that's the case, start searching backwards in your code or use the dbstop function to set a breakpoint to determine exactly where in the code the plot function gets called. As stated in the description of the file input on that documentation page, "If file is not a MATLAB code file (for instance, it is a built-in or MDL-file), then MATLAB issues a warning. MATLAB cannot pause in the file, so it pauses before executing the file."
anant mehrotra
anant mehrotra 2020-1-24
Thank you for the suggestion. I think it has to do with my mathematical operation being carried on something which is graphical.
The section profile, since I am using a rectangular section has the dimensions a and b, where b=1.2 mm. Now I wish to change the section width i.e., b. So I am reading the file and using 'fprintf', writing a new value assigning b=%5.4f which is equal to half of t_2(i), i.e. I am using a mathematical operation 0.5*t_2(i)
Secondly, the program is giving error in the very intial stages where I am assigning values t_2 to be used later. But Matlab keeps giving me the following error:
>>> variable t_2 is undefined.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by