help mee (ideal gas equation in appdesigner)

1 visualización (últimos 30 días)
Bruno Alvarez
Bruno Alvarez el 20 de Abr. de 2022
Respondida: Nivedita el 8 de Dic. de 2023
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);

Respuestas (1)

Nivedita
Nivedita el 8 de Dic. de 2023
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.

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by