help mee (ideal gas equation in appdesigner)

1 回表示 (過去 30 日間)
Bruno Alvarez
Bruno Alvarez 2022 年 4 月 20 日
回答済み: Nivedita 2023 年 12 月 8 日
global t V1 V2
syms V t V1 V2
F=str2sym('P=1*8.314*t/V');
W=int(F,V,V1,V2);
conv=arrayfun(@char,W,'uniform',0);
conv=cell2mat(conv);
app.resultadoEditField=conv;
global t
value = app.tempEditField.Value;
t=value;
end
% Value changed function: v1EditField
function v1EditFieldValueChanged(app, event)
global V1
value = app.v1EditField.Value;
V1=value;
end
% Value changed function: v2EditField
function v2EditFieldValueChanged(app, event)
global V2
value = app.v2EditField.Value;
V2=value;
error
Error using symengine
Invalid integrand.
Error in sym/int (line 177)
rSym = mupadmex('symobj::intdef',f.s,x.s,a.s,b.s,options);

回答 (1 件)

Nivedita
Nivedita 2023 年 12 月 8 日
Hello Bruno,
I understand that you are encountering is due to an invalid integrand being passed to the "int" function. This usually happens when the expression to be integrated is not properly defined or when the symbolic variables involved are not correctly initialized.
In your MATLAB code, you are trying to integrate the function "F" with respect to "V" from "V1" to "V2". The function "F" is defined as "P = 1*8.314*t/V". However, there's an issue with the way you've defined "F". You've used "str2sym" to convert a string to a symbolic expression, but you've included "P=" in the string, which is not necessary and could be causing the problem.
Here's how you can correct the code:
% Define the symbolic variables
syms V t V1 V2
% Define the function F to integrate (removed 'P=')
F = 1 * 8.314 * t / V;
% Perform the integration with respect to V from V1 to V2
W = int(F, V, V1, V2);
% Convert the symbolic expression to a string
conv = char(W);
I hope this helps!
Regards,
Nivedita.

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by