Error using cos Not enough input arguments. HELP

Hi all,
Can anyone help me with this problem - Error using cos Not enough input arguments.
x=0:0.25:5.*pi;
y=0:0.25:2.*pi;
[x,y]=meshgrid(x,y);
z = cos.*((x).*sin(y)).*((1-3.*cos((y).^2))-(x.^2).*sin((y).^2)).*cos(x);
Error using cos Not enough input arguments.
I'm new to MatLab and I need to plot a contour map using this function but I can't seem to find a way to get rid of the error message. Any help would be much appreciated.
Thanks, Kayn.

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 11 月 6 日
編集済み: Azzi Abdelmalek 2013 年 11 月 6 日

1 投票

You missed something in cos.* ,maybe you want
z = cos(x).*((x).*sin(y)).*((1-3.*cos((y).^2))-(x.^2).*sin((y).^2)).*cos(x);
You missed something in cos.

4 件のコメント

Gnaneswar Nadh satapathi
Gnaneswar Nadh satapathi 2013 年 11 月 6 日
編集済み: Azzi Abdelmalek 2013 年 11 月 6 日
clc
clear all
close all
x=0:0.25:5.*pi;
y=0:0.25:2.*pi;
[x,y]=meshgrid(x,y);
z = (cos(x).*sin(y)).*((1-3.*cos((y).^2))-(x.^2).*sin((y).^2)).*cos(x);
contour(x,y,z)
Kayn
Kayn 2013 年 11 月 6 日
Hi Azzi, Thanks for the reply. Although your solution removes the error it changes the equation. It has however highlighted the area where the error is occurring. I basically need the code then for this part of the function - cos(xsin(y))
Your answer gives (cos(x))(xsin(y)) which although removes the error, it doesn't give the correct equation describing the energy interaction I'm working on.
So, does anyone know how to write cos(xsin(y)) in MatLab syntax? I figured it would be cos(x.*sin(y)) or cos.*(x.*sin(y)) but both give the error code.
Cheers
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 11 月 6 日
The right answer is
cos(x.*sin(y))
Kayn
Kayn 2013 年 11 月 6 日
Yes, this works! Many, many thanks Azzi. I now have my contour maps and am trying to make them look nice. Thanks again.

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

その他の回答 (2 件)

Diego David Tubay Lozano
Diego David Tubay Lozano 2021 年 3 月 6 日

0 投票

diff(sin^2*([cos^2*(x^2)]))
Error using sin
Not enough input arguments.
help.

1 件のコメント

Walter Roberson
Walter Roberson 2021 年 3 月 6 日
syms x
diff(sin(x)^2 * cos(x^2)^2, x)
ans = 
or possibly you meant
syms x
diff(sin(cos(x^2)^2)^2, x)
ans = 

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

Muhammad Syahmi Mohd Shamshul
Muhammad Syahmi Mohd Shamshul 2021 年 6 月 28 日

0 投票

5*cos(x)+4.2501-cos*(0.52367-x)
Error using cos
Not enough input arguments.
Error in Secant2 (line 13)

1 件のコメント

Walter Roberson
Walter Roberson 2021 年 6 月 29 日
You have a function named Secant2 that takes at least one parameter, that is named x in the function.
When you ran the function Secant2 you did not provide any parameters at the time of the call. You probably just pressed the big green Run button. When you press the green Run button, MATLAB will run the function without providing any parameters. If you run a function that has a variable (such as x) defined as a parameter, but you run the function without providing a value in that position, then MATLAB will never go hunting around elsewhere looking for an "x" defined somewhere to use as the value in the function. For example,
x = pi/7
y = sin
if sin were defined like
function sx = sin(x)
then MATLAB will never go looking in the workspace to find the pi/7 value to use for the function. If you want a function to use a parameter, then you have to pass the parameter to it.

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

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by