# help mee (ideal gas equation in appdesigner)

3 visualizaciones (últimos 30 días)
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);
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)
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (1)

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.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Code Performance en Help Center y File Exchange.

R2022a

### Community Treasure Hunt

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

Start Hunting!

Translated by