フィルターのクリア

How to fix the semilogx function for figure 5.31..

2 ビュー (過去 30 日間)
Eugene Ouchi
Eugene Ouchi 2023 年 11 月 12 日
回答済み: Ishu 2023 年 11 月 30 日
For a class project, I have been asked to simulate the graphs in my textbook. I have copied down the equation for both the turbojet and the turbofan conditions using the syms and the subs function. However, it seems like all the functions in there are "imaginary" and because of that, the lines and functions won't appear on the tables as well. I have tried assigning the function for loops and if statements in there but if I do that, every single one of my functions that I used subs will be assigned as NaN and it wouldn't appear on the graph either. I have also utilized the hold on and off functions but MATLAB doesn't seem to create different tables either for each of the sections too. I am also having issues where the semilogx function on line 552 is being weird by giving off the message (which is my main concern):
> In Project_112 (line 552)
Error using semilogx
Data must be numeric, datetime, duration or an array convertible to double.
Error in Project_112 (line 556)
semilogx(piC,T3hth_M2)
I would also appreciate help on the NaN issues as well.
Thank you very much in advance
I will attach the textbook link onto here to show it is supposed to be like from pages 164 to 189, covering sections 5.4 and 5.5
https://drive.google.com/file/d/1BHGp-WRUAC8urLupjp4cgcKE42LNfhti/view

回答 (1 件)

Ishu
Ishu 2023 年 11 月 30 日
Hi Eugene Ouchi,
I understand that you are trying to plot the equations using "semilogx" function of MATLAB.
I tried to reproduce the error at my end and I also got the same error. On line 552 you are plotting "T3hp_M2" on the y-axis and if you try to print the values of "T3hp_M2" you will get to know that it contains imaginary part also that is why "semilogx" was giving error.
In order to plot complex values, you can try below approach:
y = [3 + 2i, 4 + 6i, 8 + 3i]; % replace with your y-data
x = [1, 10, 100]; %replace with your x data
% Extract the real and imaginary parts
real_part = real(y);
imaginary_part = imag(y);
% Plot the real and imaginary parts separately
figure;
subplot(2, 1, 1); % Create two subplots, one for real part and one for imaginary part
semilogx(x, real_part, "o"); % Plot real part
title('Real Part');
subplot(2, 1, 2);
semilogx(x, imaginary_part, "o"); % Plot imaginary part
title('Imaginary Part');
You can also plot real and imaginary part on the same axes.
For more information you can refer these documentations:
Hope it helps.

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by