how to numerically define 1/x^2+0.4/(60-x)^2

1 回表示 (過去 30 日間)
Matthew Aranda Weale
Matthew Aranda Weale 2019 年 11 月 2 日
編集済み: John D'Errico 2019 年 11 月 2 日
trying to define I= 1/x^2+0.4/(60-x)^2 numerically but says matrix dimensions must agree so incorrect use of /
help

回答 (2 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 11 月 2 日
編集済み: KALYAN ACHARJYA 2019 年 11 月 2 日
x=10; %define x, here is just an example
I=1/x^2+0.4/(60-x)^2

John D'Errico
John D'Errico 2019 年 11 月 2 日
編集済み: John D'Errico 2019 年 11 月 2 日
If x is a vector or array, then you are trying to compute element-wise operations. But / and ^ and * are all operators that are defined in terms of MATRIX multiplies and linear algebra.
Use the ./ .^ and .* operators for element-wise operations.
I= 1./x.^2+0.4./(60-x).^2
Ideas like this would be found in the getting started tutorials for MATLAB. Essenitally, it is always a good idea to read the manual.

カテゴリ

Help Center および File ExchangeOperators and Elementary Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by