Undefined operator '-' for input arguments of type 'cell'.
1 view (last 30 days)
Show older comments
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)
0 Comments
Answers (1)
Image Analyst
on 15 Sep 2018
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)
0 Comments
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!