ans = 
How can I solve the problem in integral code?
Vous suivez désormais cette question
- Les mises à jour seront visibles dans votre flux de contenu suivi.
- Selon vos préférences en matière de communication il est possible que vous receviez des e-mails.
Une erreur s'est produite
Impossible de terminer l’action en raison de modifications de la page. Rechargez la page pour voir sa mise à jour.
Afficher commentaires plus anciens
0 votes
Partagez un lien vers cette question
Solve the problem
Réponse acceptée
1 vote
Partagez un lien vers cette réponse
Loop over the values of the sigma-vector - thus call "vpaintegral" for each sigma value separately.
Or alternatively make your code a function and call it from a script with a single sigma-value as input.
Further, I'd recommend first to use "integral" instead of "vpaintegral" to save computation time.
And where do you compute w1 - w6 - the variables you try to plot at the end of your code ?
Works because "vpaintegral" is called for each sigma-value separately:
syms r
f = r^2;
sigma = 0:0.1:1;
arrayfun(@(sigma)vpaintegral(f,r,0,sigma),sigma)
Does not work because "vpaintegral" is called once with the complete sigma-vector:
syms r
f = r^2;
sigma = 0:0.1:1;
vpaintegral(f,r,0,sigma)
Operands to the logical AND (&&) and OR (||) operators must be convertible to logical scalar values. Use the ANY or ALL functions to reduce operands to logical scalar values.
Error in sym/vpaintegral (line 182)
(isinf(b) && isempty(symvar(b)) && ~isreal(b))
8 commentaires
Shreen El-Sapa
le 12 Mai 2025
Partagez un lien vers ce commentaire
Torsten
le 12 Mai 2025
Partagez un lien vers ce commentaire
It's the same problem as above. "vpaintegral" can integrate one function over one interval of integration at a time. Thus alpha must be a single value when you call "vpaintegral", not a vector of values.
Shreen El-Sapa
le 12 Mai 2025
Partagez un lien vers ce commentaire
Thanks I will try to use it.
Shreen El-Sapa
le 12 Mai 2025
Partagez un lien vers ce commentaire
Excuse me, Can I do this for 6 integrals?
Shreen El-Sapa
le 12 Mai 2025
Déplacé(e) : Torsten
le 12 Mai 2025
Partagez un lien vers ce commentaire
please see this:
Torsten
le 12 Mai 2025
Partagez un lien vers ce commentaire
Try the attached revised code.
Walter Roberson
le 12 Mai 2025
Partagez un lien vers ce commentaire
Note that vpaintegral() can handle the case where the part to be integrated is non-scalar, but cannot handle the case where the limits to integration are non-scalar.
syms x
vpaintegral([sin(x), cos(x)], x, [0 1])
ans = 
Partagez un lien vers ce commentaire
Thank you for the info.
So the changes to your last code (test_microstrength.m) were not necessary (except for the final plotting).
Plus de réponses (0)
Catégories
En savoir plus sur Calculus dans Centre d'aide et File Exchange
Voir également
le 12 Mai 2025
le 13 Mai 2025
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
