simple x.y plot
显示 更早的评论
%Q2) Create a variable 𝑥 which is a vector containing multiples of 5 between
% 0 and 50.
x = (0:5:50)
% Compute the function 𝑦 and plot it against 𝑥 using red colour dash line
% with circle markers:
y = (4*(x^2)*log(6))+(5*(x^2)) / sqrt (cos(x).^2) +1
plot (x,y, r--o)
1 个评论
Markers inside the plot function are accessed using strtings/chars
%Q2) Create a variable 𝑥 which is a vector containing multiples of 5 between
% 0 and 50.
x = (0:5:50);
% Compute the function 𝑦 and plot it against 𝑥 using red colour dash line
% with circle markers:
y = ((4*(x.^2)*log(6))+(5*(x.^2))) ./ (sqrt (cos(x).^2)+1 );
plot (x,y, '--ro') % remember markers are accessed using strings/chars
Matlab intreprets any text placed outisde the chars/strings as variables of other data types and expects input values to those variables.
help plot
回答(1 个)
Torsten
2024-3-5
Use
y = (4*(x.^2)*log(6))+(5*(x.^2)) ./ sqrt (cos(x).^2) +1
instead of
y = (4*(x^2)*log(6))+(5*(x^2)) / sqrt (cos(x).^2) +1
2 个评论
Newer users tend to encounter this type of problem frequently as they start learning MATLAB. A couple releases ago (after 20 years I can't always remember offhand when we made certain changes :) I believe we enhanced the error message to try to provide more information about how to solve the problem.
%Q2) Create a variable 𝑥 which is a vector containing multiples of 5 between
% 0 and 50.
x = (0:5:50)
% Compute the function 𝑦 and plot it against 𝑥 using red colour dash line
% with circle markers:
y = (4*(x^2)*log(6))+(5*(x^2)) / sqrt (cos(x).^2) +1
Is there any information you think could be added to this message or a way to rephrase some or all of it that would help users (especially newer users) to more effectively understand the problem and correct it themselves, without having to reach out to Answers or other MATLAB experts in their vicinity?
Torsten
2024-3-6
Is there any information you think could be added to this message or a way to rephrase some or all of it that would help users (especially newer users) to more effectively understand the problem and correct it themselves, without having to reach out to Answers or other MATLAB experts in their vicinity?
Maybe by including a link to a documentation page where Array vs. Matrix Operations are explained in examples ?
Like here:
?
类别
在 帮助中心 和 File Exchange 中查找有关 Graphics Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
