Hi I want to initialize my variable calcul_Pression but it doesn't seem to work .
clear all,clc
[t,n]= pfe();
if t=0
calcul_Pression=10^15
end
%Calcul pression:
calcul_Pression=15000*8.3144621*1e+6*(n(:,1)+n(:,2)+n(:,3)+n(:,4)+n(:,5)...
+n(:,6)+n(:,7)+n(:,8)+n(:,9)+n(:,10)+n(:,11)+n(:,12)+n(:,13)+n(:,14)...
+n(:,15)+n(:,16)+n(:,17)+n(:,18)+n(:,19)+n(:,20)+n(:,21)+n(:,22)+n(:,23)+n(:,24)...
+n(:,25)+n(:,26)+n(:,27)+n(:,28)+n(:,29)+n(:,30)+n(:,31)+n(:,32)+n(:,33)...
+n(:,34)+n(:,35)+n(:,36)+n(:,37)+n(:,38)+n(:,39)+n(:,40)+n(:,41)...
+n(:,42)+n(:,43))
pressure=[t,calcul_Pression]
plot(t,calcul_Pression,'-r')
xlabel('Temps')
ylabel('Pression(Pascal)')
legend('pression')
grid minor
grid on

4 件のコメント

Image Analyst
Image Analyst 2021 年 7 月 5 日
編集済み: Image Analyst 2021 年 7 月 5 日
What is the value of t (so we know if line 4 got executed)? Regardless, line 7 should get executed and assign something to calcul_Pression.
To fix, see this link:
Imene Yed
Imene Yed 2021 年 7 月 5 日
I verified my variables on my workspace .at t=0 I found another value not 1e15 ,it didn't execute the line 4
Walter Roberson
Walter Roberson 2021 年 7 月 5 日
if t=0
That is invalid syntax. Comparison is == not =
Imene Yed
Imene Yed 2021 年 7 月 5 日
@Walter Roberson I tried it ,but when I check my workspace at t=0 ,I got other values than 10^15.

サインインしてコメントする。

 採用された回答

Walter Roberson
Walter Roberson 2021 年 7 月 5 日

0 投票

plot(t,calcul_Pression,'-r')
You did not use any marker on that plot() call. That implies that you are expecting t and calcul_pression to both be vectors. But
if t==0
would be equivalent to
if all(t==0)
which would be true only if every single t value is exactly 0. Which is unlikely for a vector of times.
What you just might want is,
%no if before this point!
%straight on after the call to pde():
calcul_Pression=15000*8.3144621*1e+6*(n(:,1)+n(:,2)+n(:,3)+n(:,4)+n(:,5)...
+n(:,6)+n(:,7)+n(:,8)+n(:,9)+n(:,10)+n(:,11)+n(:,12)+n(:,13)+n(:,14)...
+n(:,15)+n(:,16)+n(:,17)+n(:,18)+n(:,19)+n(:,20)+n(:,21)+n(:,22)+n(:,23)+n(:,24)...
+n(:,25)+n(:,26)+n(:,27)+n(:,28)+n(:,29)+n(:,30)+n(:,31)+n(:,32)+n(:,33)...
+n(:,34)+n(:,35)+n(:,36)+n(:,37)+n(:,38)+n(:,39)+n(:,40)+n(:,41)...
+n(:,42)+n(:,43));
calcul_Pression(t==0) = calcul_Pression=10^15;
This calculates calcul_Pression at all locations, and then overwrites the calculated value at any location corresponding where t matches 0.

1 件のコメント

Imene Yed
Imene Yed 2021 年 7 月 5 日
thank you so much you've helping me a lot .

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeVariables についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by