why do I still get error with syntax

Can someone please tell me what I am doing wrong!!
%Purpose:Plot using ezpolar function
%set value for variables
p=1000;
e=0.25;
%create function handle
r=@theta p\(1-(e*cos(theta)))
%use ezpolar to plot function
ezpolar(r)
I keep getting this error
Error: File: plot_using_EZZ_polarr.m Line: 6 Column: 11
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error.
To construct matrices, use brackets instead of parentheses.

回答 (1 件)

KSSV
KSSV 2021 年 3 月 19 日
編集済み: KSSV 2021 年 3 月 19 日

0 投票

p=1000;
e=0.25;
%create function handle
r = @(theta) p\(1-(e*cos(theta))) %<--- bracket is needed here
%use ezpolar to plot function
ezpolar(r)

3 件のコメント

Aminata camara
Aminata camara 2021 年 3 月 19 日
how should I put the bracket ?
KSSV
KSSV 2021 年 3 月 19 日
I have already included the bracket.....did you run the code?
Aminata camara
Aminata camara 2021 年 3 月 19 日
it did not work at first then when I close matlab and reopen it now it works thank you

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

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

タグ

質問済み:

2021 年 3 月 19 日

コメント済み:

2021 年 3 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by