Need help with this code. Not sure what I am doing wrong.

Keep getting this error, and I'm not sure if I am doing this right at all.

回答 (1 件)

VBBV
VBBV 2023 年 2 月 18 日

0 投票

fprintf('hoop stress for inner radius cylinder, r = b: %0.2f\n', sigma_theta_theta1)

4 件のコメント

VBBV
VBBV 2023 年 2 月 18 日
編集済み: VBBV 2023 年 2 月 18 日
sigma_theta_theta1 is a numeric value/vector and not a function. So, use the variable as is in fprintf . You are trying to access the elements of that array using noninteger values from vector b of numeric array. Matlab uses only positive integer indexing to access elements from an array. Similarly for remaining lines.
Kolby Rappel
Kolby Rappel 2023 年 2 月 18 日
Okay, thank you. That works. However I am still having an error as shown in line 25. Now sure how to correct this
VBBV
VBBV 2023 年 2 月 18 日
編集済み: VBBV 2023 年 2 月 18 日
sigma_theta_theta1 is a variable with numeric values. If you look at the workspace present adjacent to command window in snapshot, it shows the variables used in your program. One of them is sigma_theta_theta1 variable with several values. Similarly others too. If you want to know more details about which class / data type it belongs to then, type the following line in command window
whos sigma_theta_theta1
VBBV
VBBV 2023 年 2 月 18 日
編集済み: VBBV 2023 年 2 月 18 日
In line 25 , Use %.4f instead, as used earlier. Do you mean warning message ?

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

カテゴリ

製品

リリース

R2022a

質問済み:

2023 年 2 月 18 日

編集済み:

2023 年 2 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by