How to fix matrix dimensions
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jonathon Klepatzki
am 10 Apr. 2024
Verschoben: Rik
am 11 Apr. 2024
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 Kommentare
Akzeptierte Antwort
the cyclist
am 10 Apr. 2024
Verschoben: Rik
am 11 Apr. 2024
In this expression
Q/pi*sigmaz*sigmay*u
only pi is going to be in the denominator.
Since your expression bears some resemblance to the PDF of a normal distribution, I expect that at least sigmaz and sigmay are also supposed to be in the denominator. Probably u as well.
I expect that you actually need
Q/(pi*sigmaz*sigmay*u)
which would give
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)
This looks to be in the ballpark of what you expected.
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!