フィルターのクリア

Undefined operator '-' for input arguments of type 'cell'.

1 回表示 (過去 30 日間)
Joseph Salerno
Joseph Salerno 2018 年 9 月 15 日
回答済み: Image Analyst 2018 年 9 月 15 日
I'm trying to input columns of data from a cell into an equation, with the hopes of it outputting multiple answers, one for each row. I've tried replacing parentheses with curly braces and using excessive parenthesis, but I can't figure it out. I'm entirely new to programming and matlab, so please go easy on me.
>> Data={'Helium','He',.0341,.0237;'Hydrogen','H2',.244,.0266;'Oxygen','O2',1.36,.0318;'Chlorine','Cl2',6.49,.0562;'Carbon dioxide','CO2',3.59,.0427}
Data =
5×4 cell array
{'Helium' } {'He' } {[0.0341]} {[0.0237]}
{'Hydrogen' } {'H2' } {[0.2440]} {[0.0266]}
{'Oxygen' } {'O2' } {[1.3600]} {[0.0318]}
{'Chlorine' } {'Cl2'} {[6.4900]} {[0.0562]}
{'Carbon dioxide'} {'CO2'} {[3.5900]} {[0.0427]}
>> Pressure=((.08206*300)/(20-{Data{:,4}}))-{Data{:,3}}/(20^2)

回答 (1 件)

Image Analyst
Image Analyst 2018 年 9 月 15 日
Try this:
Data={'Helium','He',.0341,.0237;'Hydrogen','H2',.244,.0266;'Oxygen','O2',1.36,.0318;'Chlorine','Cl2',6.49,.0562;'Carbon dioxide','CO2',3.59,.0427}
% Data =
% 5×4 cell array
% {'Helium' } {'He' } {[0.0341]} {[0.0237]}
% {'Hydrogen' } {'H2' } {[0.2440]} {[0.0266]}
% {'Oxygen' } {'O2' } {[1.3600]} {[0.0318]}
% {'Chlorine' } {'Cl2'} {[6.4900]} {[0.0562]}
% {'Carbon dioxide'} {'CO2'} {[3.5900]} {[0.0427]}
column3 = cell2mat(Data(:, 3))
column4 = cell2mat(Data(:, 4))
Pressure = ((.08206*300) ./ (20-column4)) - column3 ./ (20^2)

カテゴリ

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

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by