Error question :The expression to the left of the equals sign is not a valid target for an assignment

3 ビュー (過去 30 日間)
Hi, i'm trying to run this sintax:
t = [0,2*pi];
r^2 = 17^2*cos(2t)+sqrt(6^4-17^4*sin(2t)^2)
polar(t,r)
and when ii run it, it says: The expression to the left of the equals sign is not a valid target for an assignment and i don't know how to make it work, i know that is a simple sintax, but i am a beginner :)!
Thanks!
  1 件のコメント
mohammad azsad
mohammad azsad 2014 年 11 月 2 日
編集済み: mohammad azsad 2014 年 11 月 2 日
yes it is wrong you can write >> t=[0:(2*pi/100):2*pi];r=sqrt((17.^2)*cos(2*t)+sqrt(((6.^4)-(17.^4)).*((sin(2*t)).^2))) polar(t,r)

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

回答 (1 件)

Harry
Harry 2014 年 11 月 2 日
編集済み: Harry 2014 年 11 月 2 日
Try this:
% Define a vector of time values
dt = 0.01;
t = 0:dt:2*pi;
r = sqrt(17^2*cos(2*t)+sqrt(6^4-17^4*sin(2*t).^2));
polar(t,r);
This is what I changed:
1) To define t on the interval [0,2*pi], you must create a vector of numbers (for example [0,0.01,0.02,...]).
2) The error you saw happened because you had "r^2" on the left hand side of an equation. In fact, you want to assign a value to "r", so just take the square root of both sides.
3) In order to calculate sin(2t)^2, you must use the ".^2" operator, since sin(2*t) is a vector and you want to raise every element to the power 2.
  3 件のコメント
Mihai
Mihai 2014 年 11 月 2 日
Ok, i understand what have you done, thank you very much an have a good day!
Harry
Harry 2014 年 11 月 3 日
Great. Please accept my answer if you are happy with it.

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

カテゴリ

Help Center および File ExchangeString についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by