How to fix matrix dimensions
Afficher commentaires plus anciens
Given the specific values of y, sigmay, and sigmaz (see code), I must calculate them and plot each line on a graph
close all;
clear all;
clc
Q = 1;
y = [10, 20, 30, 40, 50, 65, 80, 100, 200, 300, 400, 500, 650, 800, 1000];
sigmay = [27, 62, 115, 165, 210];
sigmaz = [14, 38, 105, 250 450];
u = 2;
for j = 1:y
for k = 1:sigmay
for l = 1:sigmaz
C = (Q./pi.*sigmay.*sigmaz.*u).*exp(-0.5.*(y./sigmay).^2); %% this is where the error is at%%
end
end
end
plot(y,C)
title('Excercise 1')
xlabel('distance (m)')
ylabel('concentrations')
grid on
As you can see, I tried using the ./ or .* but, it didn't work.
4 commentaires
You seem to be mixing up loops with vectorized code. How about:
Q = 1;
y = [10, 20, 30, 40, 50, 65, 80, 100, 200, 300, 400, 500, 650, 800, 1000];
sigmay = [27, 62, 115, 165, 210];
sigmaz = [14, 38, 105, 250 450];
u = 2;
C = (Q./pi.*sigmay.*sigmaz.*u).*exp(-0.5.*(y(:)./sigmay).^2)
Jonathon Klepatzki
le 10 Avr 2024
Modifié(e) : Jonathon Klepatzki
le 10 Avr 2024
Stephen23
le 10 Avr 2024
"Any suggestions?"
Do you have a reference for the formula?
Jonathon Klepatzki
le 10 Avr 2024
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Aerospace Applications dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!