How to add two sets of imported data?

2 views (last 30 days)
Ashley Bhugwandin
Ashley Bhugwandin on 7 Dec 2021
Commented: Peter Perkins on 10 Dec 2021
I am currently working on a program that requires me to add two sets of data that is imported in tables. However whenever I run the code, I get this error message:
Operator '+' is not supported for operands of type 'table'.
Error in MastersDraft_1 (line 3)
Moisture_content = plus(Lime_additioncombinedprdts,Lime_additioncombinedprdtsratio);
How do I fix it?

Sign in to comment.

Answers (1)

Peter Perkins
Peter Perkins on 7 Dec 2021
Ashley, there's a long example in the doc that talks about "how to perform calculations by using the numeric and categorical data that the table contains" at length:
Without more information in your question, the short answer is to do things like
t.X = t.X + 1
tplus1 = varfun(@(x)x+1,t)
or perhaps
t{:,["X" "Y" "Z"]) = t{:,["X" "Y" "Z"]) + 1
t.Variables = t.Variables + 1

Community Treasure Hunt

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

Start Hunting!