変数に入れた計算式を計算する方法

조회 수: 8 (최근 30일)
Ibuki Takahashi
Ibuki Takahashi 2021년 7월 7일
답변: Hernia Baby 2021년 7월 7일
matlabのプログラムの中で、iという変数の中に1+1という計算式を格納しました。
この変数を表示させると、そのまま1+1が表示されますが、変数に格納した計算式を計算する関数などはございますでしょうか。
よろしくお願いします。

채택된 답변

Hernia Baby
Hernia Baby 2021년 7월 7일
計算式(文字)を数値に変換する場合は、データ型を変更する必要があります。
clear,clc;
s = "1 + 1"
s = "1 + 1"
s1 = str2num(s)
s1 = 2

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!